/** * Search file for matching addon annotations and automaticly resolve and add them into their collections * * @param \Codex\Addons\Scanner\ClassFileInfo $file */ public function resolveAndRegister(ClassFileInfo $file) { $class = $file->getClassName(); if (array_key_exists($class, $this->registered)) { return; } $this->registered[$class] = $file; foreach ($file->getClassAnnotations() as $annotation) { if ($annotation instanceof Annotations\Processor) { $this->processors->add($file, $annotation); } elseif ($annotation instanceof Annotations\Hook) { $this->hooks->add($file, $annotation); } elseif ($annotation instanceof Annotations\Plugin) { $this->plugins->add($file, $annotation); } } foreach ($file->getMethodAnnotations(true) as $method => $annotations) { foreach ($annotations as $annotation) { if ($annotation instanceof Annotations\Hook) { $this->hooks->add($file, $annotation, $method); } } } foreach ($file->getPropertyAnnotations(true) as $property => $annotations) { foreach ($annotations as $annotation) { } } }
/** * sortAssets method * * @param array|Collection $all * * @return \Codex\Support\Collection */ protected function sorter($all = []) { /** @var Collection $all */ $all = $all instanceof Collection ? $all : new Collection($all); $sorter = new Sorter(); $sorted = new Collection(); foreach ($all as $name => $asset) { $sorter->addItem($asset['name'], $asset['depends']); } foreach ($sorter->sort() as $name) { $sorted->add($all->where('name', $name)->first()); } return $sorted; }
protected function button($id, array $data = [], $gid = null) { $this->buttons->add(new Button($id, $data, $gid)); }