/** * Scans the given $file, looking for a list of functions that we want to identify * to locate custom capabilities, taxonomies, etc... * * Creates meta objects for everything that we find. * * @param AnalyzedFile $file The file to scan * @param FileRenderer $file_renderer The meta object for this file. */ public function scan_file($file, $file_renderer) { $function_calls = $file->get_code_elements('function_calls'); foreach ($this->resource_types as $resource) { foreach ($resource['func_name'] as $function_name) { foreach ($function_calls as $call_path => $functions) { // check and see if this function was called if (array_key_exists($function_name, $functions)) { if (isset($functions[$function_name]['args'])) { $calls = array($functions[$function_name]); } else { $calls = $functions[$function_name]; } foreach ($calls as $call) { $child_renderer = new ResourceRenderer(str_replace($this->remove_chars, '', $call['args'][0])); $child_renderer->set_resource_type($resource['singular'], $resource['plural']); $child_renderer->add_attribute('file', $file->get_filename()); $child_renderer->add_attribute('args', $call['args']); $file_renderer->add_child($child_renderer); $this->renderers[$resource['plural']]->add_child($child_renderer); } } } } } }
/** * * @param AnalyzedFile $file * @param AnalyzerRenderer $renderer */ public function add_renderers($file, &$renderer, $path = '', $hierarchy = null) { if (is_null($hierarchy)) { $hierarchy = $this->check_hierarchy; } foreach ($hierarchy as $level => $hierarchy_children) { $code_elements = $file->get_code_elements($level, $path); if (empty($code_elements)) { $this->add_renderers($file, $renderer, $path, $hierarchy_children); } else { foreach ($code_elements as $child_path => $child_element) { if (array_key_exists($level, $this->hierarchy_metas)) { $child_meta = new $this->hierarchy_metas[$level]($child_path); $child_meta->add_attribute('file', $file->get_filename()); foreach ($child_element as $prop_name => $prop_value) { $child_meta->add_attribute($prop_name, $prop_value); } $this->add_renderers($file, $child_meta, $child_path, $hierarchy_children); $renderer->add_child($child_meta); // If the path is empty add this to the list of root metas if (empty($path)) { $this->renderers[$level]->add_child($child_meta); } } else { $this->add_renderers($file, $renderer, $child_path, $hierarchy_children); } } } } }
/** * * @param AnalyzedFile $file The file this meta is for. * @param array $attributes */ function __construct($file, $attributes = array()) { parent::__construct($file->get_filename(), $attributes); $this->set_file($file); }
/** * * @param AnalyzedFile $file The file this meta is for. * @param array $attributes */ function __construct($file) { $this->name = $file->get_filename(); $this->set_file($file); }