Exemple #1
0
 public static function install()
 {
     exec('cat ' . shared_storage_dir() . '/*.cron | crontab', $output, $return_code);
     if (!empty($output)) {
         throw new Exception(json_encode($output));
     }
     return $return_code === 0;
     // $tasks = array();
     // static::all()->each(function ($task) use (&$tasks) {
     // 	array_push($tasks, $task->toString());
     // });
     // file_put_contents(__DIR__ . '/../storage/crontab', join("\n", $tasks));
 }
Exemple #2
0
 /**
  * Get a template module instance, trying to fallback to a general template
  * @param string name
  * @return Module
  */
 public static function template($name)
 {
     $template = null;
     //
     // It's a template name or template contents?
     //
     if (preg_match('/^[A-Za-z0-9_\\.\\-\\/]+\\.html$/', $name)) {
         // It's a template name!
         $template = static::get(self::TYPE_TEMPLATE, $name);
         if (!$template) {
             $fallback_template_path = shared_storage_dir() . '/default/templates/' . $name;
             // try to retrieve local fallback template
             if (!file_exists($fallback_template_path)) {
                 throw new Exceptions\MethodFailureException("Template not found: '{$name}'. Please run `hook generate:template {$name}` to generate one.");
             }
             // use local template if can't find
             $template = new static(array('type' => self::TYPE_TEMPLATE, 'code' => file_get_contents($fallback_template_path), 'name' => $name));
         }
     }
     if (!$template) {
         $template = new static(array('type' => self::TYPE_TEMPLATE, 'code' => $name, 'name' => 'inline-template.html'));
     }
     return $template;
 }