Skip to content

Instantly share code, notes, and snippets.

@vincenzo
Created March 15, 2012 11:16
Show Gist options
  • Save vincenzo/2043713 to your computer and use it in GitHub Desktop.
Save vincenzo/2043713 to your computer and use it in GitHub Desktop.
Programmatic CCK Content Type Updated - Step 6 - part 2
<?php
/**
* Implementation of hook_requirements()
*/
function example_cck_content_requirements($phase) {
$requirements = array();
$t = get_t();
// an array of the dependencies
// where the array key is the module machine-readable name
// and the value is the module human-readable name
$dependencies = array(
'content' => 'Content',
'filefield' => 'FileField',
'imagefield' => 'ImageField',
'text' => 'Text',
);
switch ($phase) {
case 'install':
$error = FALSE;
$value = '';
foreach ($dependencies as $dependency =&gt; $module_nice_name) {
if (!module_exists($dependency)) {
$error = TRUE;
$value .= $t($module_nice_name . &quot; to be pre - installed; &quot;);
$severity = REQUIREMENT_ERROR;
}
}
if ($error) {
$requirements['example_cck_content'] = array(
'title' => $t('Example CCK Content requires: '),
'value' => $value . $t(' if the required modules are now installed, please enable this module again.'),
'severity' => $severity,
);
}
break;
}
return $requirements;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment