class Pattern in Patterns 6.2
Hierarchy
- class \Pattern
Expanded class hierarchy of Pattern
File
- ./
pattern.class.php, line 2
View source
class Pattern {
private $info = array(
'title' => "",
'description' => "",
'author' => "",
'author_email' => "",
'category' => "",
'version' => "0.1",
);
private $modules = array();
private $actions = array();
function __construct($title, $author, $author_email) {
$this
->info('title', $title);
$this
->info('author', $author);
$this
->info('author_email', $author_email);
}
public function info($key = null, $value = null) {
if ($key == null) {
return $this->info;
}
$this->info[$key] = $value;
}
public function modules($modules_list) {
$modules = self::list_to_array($modules_list);
$this->modules = array_merge($this->modules, $modules);
}
// Actions
private function action($tag, $data) {
$this->actions[] = array_merge($data, array(
'tag' => $tag,
));
}
public function variable($name, $value) {
$this
->action('variable', array(
'name' => $name,
'value' => $value,
));
}
public function view($name, $description, $tag, $base = "node") {
$view = new PatternView($name, $description, $tag, $base);
$this
->action('view', array(
'patterns_object' => $view,
));
return $view;
}
// Utility
public function export() {
foreach ($this->actions as &$action) {
if (array_key_exists('patterns_object', $action)) {
$data = $action['patterns_object']
->export();
// TODO: export shouldn't be destructive
unset($action['patterns_object']);
$action = array_merge($action, $data);
}
}
return array(
'info' => $this->info,
'modules' => $this->modules,
'actions' => $this->actions,
);
}
private static function list_to_array($list) {
return explode(",", preg_replace("/[,\\s]+/", ",", $list));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Pattern:: |
private | property | ||
Pattern:: |
private | property | ||
Pattern:: |
private | property | ||
Pattern:: |
private | function | ||
Pattern:: |
public | function | ||
Pattern:: |
public | function | ||
Pattern:: |
private static | function | ||
Pattern:: |
public | function | ||
Pattern:: |
public | function | ||
Pattern:: |
public | function | ||
Pattern:: |
function |