Last active
December 11, 2015 01:19
-
-
Save phalcon/4522325 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RoutePrefix: /posts | |
| Route: Array | |
| ( | |
| [0] => /edit/{id} | |
| [methods] => Array | |
| ( | |
| [0] => GET | |
| [1] => POST | |
| ) | |
| [name] => edit-product | |
| [paths] => Array | |
| ( | |
| [module] => frontend | |
| ) | |
| ) | |
| param |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @RoutePrefix("/posts") | |
| */ | |
| class ProductsController | |
| { | |
| /** | |
| * Edits a product | |
| * | |
| * @Route("/edit/{id}", methods={"GET", "POST"}, | |
| * name="edit-product", paths={module=frontend}) | |
| * @param int $id | |
| */ | |
| public function editAction($id) | |
| { | |
| } | |
| } | |
| //Create a memory annotations manager | |
| $annotations = new Phalcon\Annotations\Adapter\Memory(); | |
| //Get the annotations refactor for ProductsController | |
| $refactor = $annotations->get('ProductsController'); | |
| //Get the class' annotations | |
| $annotations = $refactor->getClassAnnotations(); | |
| //Iterate over them | |
| foreach ($annotations as $annotation) { | |
| echo $annotation->getName(), ': ', join(', ', $annotation->getArguments()), PHP_EOL; | |
| } | |
| //Get the method's annotations | |
| $annotations = $refactor->getMethodAnnotations(); | |
| //Iterate over them | |
| foreach ($annotations as $method => $methodAnnotations) { | |
| foreach ($methodAnnotations as $annotation) { | |
| if ($annotation->numberArguments()) { | |
| echo $annotation->getName(), ': '; | |
| print_r($annotation->getArguments()); | |
| echo PHP_EOL; | |
| } else { | |
| echo $annotation->getName(), PHP_EOL; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment