/**
  * Configures the class writer and makes it generate the
  * test classes required by the object type.
  */
 protected function generateTest()
 {
     $destination = implode(DIRECTORY_SEPARATOR, array("test", "Middleware", $this->classname . "Test.php"));
     $namespace = Strata::getNamespace() . "\\Test\\Middleware";
     $writer = $this->getWriter();
     $writer->setClassname($this->classname);
     $writer->setNamespace($namespace);
     $writer->setDestination($destination);
     $writer->setUses("\nuse Strata\\Test\\Test as StrataTest;\n");
     $writer->setExtends("StrataTest");
     $writer->create(true);
 }
Exemplo n.º 2
0
 /**
  * Generates a possible namespace and classname combination of a
  * Strata objecy. Mainly used to avoid hardcoding the '\\View\\Helper\\'
  * string everywhere (or whatever else would the namespace have been).
  * @param  string  $name  The class name of the object
  * @param  boolean $local Generated a path that is relative to the current project. Default to false.
  * @return string       A fully namespaced name
  */
 public static function generateClassPath($name, $local = true)
 {
     $paths = array($local ? Strata::getNamespace() : 'Strata', self::getNamespaceStringInStrata(), self::generateClassName($name));
     return implode("\\", $paths);
 }
Exemplo n.º 3
0
 /**
  * Configures the class writer and makes it generate the
  * test classes required by the accompanying model entity.
  */
 protected function generateEntityTest()
 {
     $classname = ModelEntity::generateClassName($this->keyword);
     $namespace = Strata::getNamespace() . "\\Test\\Model\\Entity";
     $destination = implode(DIRECTORY_SEPARATOR, array("test", "Model", "Entity", $classname . "Test.php"));
     $writer = $this->getWriter();
     $writer->setClassname($classname . "Test");
     $writer->setNamespace($namespace);
     $writer->setDestination($destination);
     $writer->setUses("\nuse Strata\\Test\\Test as StrataTest;\n");
     $writer->setExtends("StrataTest");
     $writer->create(true);
 }
Exemplo n.º 4
0
 private function loadProjectMiddlewares()
 {
     $possibleMiddlewareLoaders = glob(Strata::getMiddlewarePath() . "*Initializer.php");
     $namespace = Strata::getNamespace() . "\\Middleware\\";
     foreach ((array) $possibleMiddlewareLoaders as $filename) {
         if (preg_match('/([^\\/\\\\]+?Initializer).php$/', $filename, $matches)) {
             $className = $namespace . $matches[1];
             if (class_exists($className)) {
                 $this->middlewares[] = new $className();
             }
         }
     }
 }