/** * 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); } } } } } }