Commit b0d636c4 authored by Liam Morland's avatar Liam Morland Committed by Lily Yan
Browse files

Coding standards

parent 513406b4
<?php
/**
* @file
* Install, update and uninstall for UW Sites all.
*/
use Drupal\node\Entity\Node;
use Drupal\pathauto\PathautoState;
/**
* Implements hook_install().
*/
function uw_sites_all_install() {
// Add web resources news feed.
$title = 'Web-resources news';
$fid = db_query('SELECT fid FROM {aggregator_feed} WHERE title = :title', array(':title' => $title))->fetchCol();
if (empty($fid)) {
$feed = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->create(array(
'uuid' => \Drupal::service('uuid')->generate(),
'title' => $title,
'url' => 'https://uwaterloo.ca/web-resources/news/news.xml',
'created' => time(),
));
$feed->save();
}
}
/**
* Implements hook_uninstall().
*/
function uw_sites_all_uninstall() {
// The transaction opens here.
$transaction = \Drupal::database()->startTransaction();
$title = "Web-resources news";
$fid = db_query('SELECT fid FROM {aggregator_feed} WHERE title = :title', array(':title' => $title))->fetchCol();
if (!empty($fid)) {
db_delete('aggregator_feed')
->condition('fid', $fid)
->execute();
db_delete('aggregator_item')
->condition('fid', $fid)
->execute();
}
}
<?php
/**
* @file
* Install, update and uninstall for UW Sites all.
*/
/**
* Implements hook_install().
*/
function uw_sites_all_install() {
// Add web resources news feed.
$title = 'Web-resources news';
$fid = db_query('SELECT fid FROM {aggregator_feed} WHERE title = :title', [':title' => $title])->fetchCol();
if (empty($fid)) {
$feed = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->create([
'uuid' => \Drupal::service('uuid')->generate(),
'title' => $title,
'url' => 'https://uwaterloo.ca/web-resources/news/news.xml',
'created' => time(),
]);
$feed->save();
}
}
/**
* Implements hook_uninstall().
*/
function uw_sites_all_uninstall() {
// The transaction opens here.
$transaction = \Drupal::database()->startTransaction();
$title = "Web-resources news";
$fid = db_query('SELECT fid FROM {aggregator_feed} WHERE title = :title', [':title' => $title])->fetchCol();
if (!empty($fid)) {
db_delete('aggregator_feed')
->condition('fid', $fid)
->execute();
db_delete('aggregator_item')
->condition('fid', $fid)
->execute();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment