Exemplo n.º 1
0
 /**
  * @Route /performance/list
  */
 public function listAction()
 {
     $cache = new \Raptor\Cache\Cache('performance');
     if ($cache->hasCache()) {
         $performance = $cache->getData();
     } else {
         $performance = new ItemList();
     }
     $series = array();
     $performance->each(function ($key, $value) use(&$series) {
         $item = new ItemList();
         $item->set('value', $value);
         $item->set('no', $key);
         $series[] = $item->getArray();
     });
     return $this->JSON(new ItemList($series));
 }
Exemplo n.º 2
0
 /**
  * @Route /resources/publisher/bundles
  */
 public function loadBundlesAction()
 {
     $bundles = new ItemList($this->app->getConfigurationLoader()->getBundlesSpecifications());
     $vendors = array();
     $bundles->each(function ($key, $value) use(&$vendors) {
         $namespace = $value['namespace'];
         if ($namespace[0] == '\\') {
             $namespace = substr($namespace, 1);
         }
         $vendor = explode('\\', $namespace);
         $vendor = $vendor[0];
         if (!isset($vendors[$vendor])) {
             $vendors[$vendor] = array();
             $vendors[$vendor][$key] = $value;
         } else {
             $vendors[$vendor][$key] = $value;
         }
     });
     $tree = array();
     unset($vendors['Raptor']);
     foreach ($vendors as $key => $value) {
         $item = array();
         $item['text'] = $key;
         $item['children'] = array();
         $item['expanded'] = true;
         $item['vendor'] = true;
         $item['iconCls'] = 'icon-vendor';
         foreach ($value as $key2 => $value2) {
             $children = array();
             $children['text'] = $key2 . '<b style="color: #402878">/Resources</b>';
             $children['bundle'] = $key2;
             $children['iconCls'] = 'icon-bundle';
             $children['expandable'] = false;
             $children['vendor'] = false;
             $children['checked'] = false;
             $children['namespace'] = $value2['namespace'];
             $item['children'][] = $children;
         }
         $tree[] = $item;
     }
     return $this->JSON($tree);
 }
Exemplo n.º 3
0
 /**
  *  Pobla los atributos de la clase o objeto especificado con los parametros provenientes en el request actual
  * @param string|Object $name
  * @param \Raptor\Util\ItemList $request
  * @param array $matcher
  * @return mixed
  * @throws \Exception
  */
 public static function run($name, \Raptor\Util\ItemList $request, $matcher = array())
 {
     $class = $name;
     $reflectionClass = new ReflectionClass($class);
     $props = $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
     foreach ($props as $prop) {
         if ($request->keyExist($prop->getName())) {
             $prop->setAccessible(true);
             $prop->setValue($class, Collector::validator($request->get($prop->getName())));
         }
     }
     foreach ($matcher as $key => $match) {
         if ($reflectionClass->hasProperty($key) and $request->keyExist($match)) {
             $reflectionClass->getProperty($key)->setAccessible(true);
             $reflectionClass->getProperty($key)->setValue($class, $request->get($match));
         } else {
             throw new \Exception("Reflection Error: the {$key} match does not exist in the class ");
         }
     }
     return $class;
 }
 /**
  * @Route /gendoctrine/schema/listClasses
  */
 public function listClassesAction($request)
 {
     $bundle = $request->post('name');
     $spc = $this->app->getConfigurationLoader()->getBundlesSpecifications();
     $absolute = $spc[$bundle]['location'];
     $supose = new ItemList(glob($absolute . '/Model/Entity/*.php'));
     $supose->each(function ($key, $value, $list) use($bundle) {
         $class = new ItemList();
         $name = explode($bundle, $value);
         $name = $name[1];
         $class->set('class', $bundle . $name);
         $className = str_replace('/Model/Entity/', '', $name);
         $className = str_replace('.php', '', $className);
         $class->set('class', $bundle . $name);
         $class->set('name', $className);
         $list->set($key, $class->getArray());
     });
     return $this->JSON($supose);
 }
 /**
  * @Route /genbundle/delete
  */
 public function deleteBundleAction($request)
 {
     $name = $request->post('name');
     $sp = $this->app->getConfigurationLoader()->getBundlesSpecifications();
     $vendor = str_replace($name, '', $sp[$name]['location']);
     $this->eliminarDir($sp[$name]['location']);
     $files = new ItemList(glob($vendor . "*"));
     if ($files->isEmty()) {
         $this->eliminarDir($vendor);
     }
     $this->app->getConfigurationLoader()->unRegisterBundle($sp[$name]['name']);
     /**
      * Cant call force load here, the Aspect Kernel has a problem with removed bundles
      * instead perform a save operation with cache
      */
     $this->app->getConfigurationLoader()->getCache()->setDirty();
     $this->app->getConfigurationLoader()->getCache()->save();
     return $this->show("Bundle {$name} deleted");
 }
Exemplo n.º 6
0
 public function remove($pos)
 {
     parent::remove($pos);
     $session = \Raptor\Raptor::getInstance()->getSession();
     $session->put($this->getArray());
 }
Exemplo n.º 7
0
 /**
  * 
  * Genera las tablas a partir de los modelos especificados en el array $classes
  * El alias no es mas que el nombre acortado del bundle de donde pertenecen los
  * modelos
  * 
  * $this->getStore()->generateSchema('exampleBundle',array('Persona'));
  * 
  * @param string $alias nombre acortado del bundle donde pertenecen los modelos
  * @param array $classes clases modelos a generar sus tablas
  */
 public function generateSchema($alias, $classes = array())
 {
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $driver = $this->entityManager->getConfiguration()->newDefaultAnnotationDriver($this->annotations);
     $this->entityManager->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->entityManager);
     $metaInformation = new ItemList($classes);
     $me = $this;
     $schemas = array();
     $metaInformation->each(function ($key, $value, $list) use(&$alias, &$cmf, &$me, &$schemas) {
         $meta = $cmf->getMetadataFor($alias . ':' . $value);
         $list->set($key, $meta);
         $tableDef = explode('.', $meta->table['name']);
         if (count($tableDef) > 1) {
             $schemas[$tableDef[0]] = $tableDef[0];
         }
     });
     $schemaTool->createSchema($metaInformation->getArray());
 }
Exemplo n.º 8
0
 /**
  * Pobla los atributos de la clase o objeto especificado con los parametros provenientes en el request actual
  * 
  * Si el primer parametro es una clase el colector crea un instancia de esta.
  * Si el primer paremtro es un objeto lo usa para poblar segun los parametros del request.
  * 
  * @param string/object $class clase u objeto a poblar
  * @param array $matcher un array con el macheo de parametros que no conciden con los atributos de la clase. ejemplo array('nombre'=>'nombre_c') en el ejemplo nombre es el parametro que viene en el request y nombre_c el que esta en la clase, el colector pone el valor de nombre en nombre_c
  * @return mixed
  */
 public function collector($class, $matcher = array())
 {
     $classTo = $class;
     if (!is_object($classTo)) {
         $alias = new ItemList(explode(':', $classTo));
         if ($alias->size() > 1) {
             $classTo = $alias->get(0);
             $namespace = $this->getStore()->getManager()->getConfiguration()->getEntityNamespace($classTo);
             $namespace .= '\\' . $alias->get(1);
             $classTo = $namespace;
         }
         $classTo = new $classTo();
     }
     return Collector::run($classTo, new ItemList($this->app->request()->params()), $matcher);
 }