Beispiel #1
0
 /**
  * This is the function that handles the files to be generated.
  *
  * @param  string $views_dir  This is the templates' directory, it contains
  * all the blade template needed
  * @param  string $cache_dir  This is used to cache templates generated from
  * blade compiler
  * @param  string $template   The template to use
  * @return void
  */
 public function make($views_dir = __DIR__ . '/Resources/views', $cache_dir = __DIR . '/Resources/cache', $template = 'index')
 {
     $reader = Reader::createFromDefaults();
     $docs = [];
     # iterate all classes and their functions
     foreach ($this->classes as $class => $functions) {
         # get the class annotations
         $anno_class = $reader->getClassAnnotations($class)->toArray();
         if (!isset($anno_class['sleekdoc_init'])) {
             continue;
         }
         if (!isset($anno_class['sleekdoc_namespace'])) {
             throw new Exception("The annotation @sleekdoc_namespace must be declared in the class of {$class}.");
         }
         if (!isset($anno_class['sleekdoc_category'])) {
             throw new Exception("The annotation @sleekdoc_category must be declared in the class of {$class}.");
         }
         $namespace = $anno_class['sleekdoc_namespace'];
         $category = $anno_class['sleekdoc_category'];
         $this->data['api'][$category][$namespace] = $anno_class;
         # iterate each functions from the class
         foreach ($functions as $func) {
             $anno_method = $reader->getMethodAnnotations($class, $func)->toArray();
             if (!isset($anno_method['sleekdoc_init'])) {
                 continue;
             }
             $this->data['api'][$category][$namespace]['functions'][] = $anno_method;
         }
     }
     return static::blade($views_dir, $cache_dir)->make($template, ['data' => $this->data]);
 }
Beispiel #2
0
/**
 * @command.spec
 * ​             _   _
 *             |_| | |
 *    ___ _ __  _  | | ___   __ _
 *   / _ \ '_ \| | | |/ _ \_/ _` |
 *  |  __/ |_) | |_| | (_) _ (_| |
 *   \___| .__/|_____|\___/ \__, |
 *       | |                 __/ |
 *       |_|                |___/
 *
 * Usage:
 *   epilog <command> [<args>...]
 *
 * Commands are:
 *   epilog watch   Monitor a log files
 *   epilog pretend Display a fake log stream, for testing only
 *
 * See 'epilog <command> -h' to read about a specific subcommand.
 *
 * Options:
 *   -h --help                Show this screen.
 *   -v --version             Show version.
 */
function epilog()
{
    $specReader = AnnotationsReader::createFromDefaults();
    $handler = new Handler(['version' => 'Epilog ' . Epilog::VERSION . ' by Márcio Almada', 'optionsFirst' => true]);
    $response = $handler->handle($specReader->getFunctionAnnotations(__FUNCTION__)->get('command.spec'));
    $command = __NAMESPACE__ . '\\' . $response['<command>'];
    if (!function_exists($command)) {
        throw new FlowException("Command `{$response['<command>']}` not defined, try epilog --help", 1);
    }
    $handler->optionsFirst = false;
    $response = $handler->handle($specReader->getFunctionAnnotations($command)->get('command.spec'));
    $command($response);
}
 /**
  * Returns the description of the Permission's class properties
  * in the format array[property_name] = [@Pff2PermissionDescription]
  *
  * @return array
  */
 public function getPrettyPermissions()
 {
     $permissionReflect = new \ReflectionClass('\\pff\\models\\' . $this->permissionClass);
     $prop = $permissionReflect->getProperties();
     $toReturnAnnotations = array();
     foreach ($prop as $a) {
         $i = $this->reader->getPropertyAnnotations('\\pff\\models\\' . $this->permissionClass, $a->name);
         $arr = $i->toArray();
         if (isset($arr['Pff2PermissionDescription'])) {
             $tmp_name = explode('_', $a->name);
             array_walk($tmp_name, function (&$arr, $k) {
                 $arr = ucfirst($arr);
             });
             $toReturnAnnotations[implode($tmp_name)] = $arr['Pff2PermissionDescription'];
         }
     }
     return $toReturnAnnotations;
 }
Beispiel #4
0
 /**
  * @return HttpMethod
  */
 protected function getHandler()
 {
     return new HttpMethod(Reader::createFromDefaults());
 }
 protected function getReturnAnnotation(ReflectionMethod $method)
 {
     $annotationsBag = Reader::createFromDefaults()->getMethodAnnotations($method->class, $method->getName());
     return $annotationsBag->get('return');
 }
Beispiel #6
0
 /**
  * @return Secure
  */
 protected function getHandler()
 {
     return new Secure(Reader::createFromDefaults());
 }
 /**
  * Retrieves a reader object
  *
  * @return Minime\Annotations\Reader
  */
 protected function reader()
 {
     if ($this->_reader === null) {
         $this->_reader = Reader::createFromDefaults();
     }
     return $this->_reader;
 }
 /**
  * Executes actions before the Controller
  *
  * @return mixed
  */
 public function doBefore()
 {
     $class_name = get_class($this->_controller);
     $this->classAnnotations = $this->reader->getClassAnnotations($class_name);
     $this->methodAnnotations = $this->reader->getMethodAnnotations($class_name, $this->_controller->getAction());
 }
Beispiel #9
0
 /**
  * @param $className
  * @return void
  */
 private function __construct($className)
 {
     $this->reader = \Minime\Annotations\Reader::createFromDefaults();
     $this->reflectionClass = new \ReflectionClass($className);
     $this->className = $className;
 }