Esempio n. 1
0
 /**
  * Gets the list of all tables.
  *
  * <code>
  *   $listTableClasses = $this->container->get('bootstrap.database.db')->listTables('table_class');
  *   $listTableClasses = array_combine($listTableClasses, $listTableClasses);
  * </code>
  * @return array    the list of all tables
  * @access public
  *
  * @author Etienne de Longeaux <*****@*****.**>
  * @since 2014-08-01
  */
 public function listTables($type = 'table_name')
 {
     $tables = array();
     switch ($type) {
         case 'table_name':
             $tables = $this->getConnection()->getSchemaManager()->listTables();
             break;
         case 'table_class':
             $meta = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();
             foreach ($meta as $m) {
                 list($domaine, $bundle, $entity) = split("\\\\", $m->getName(), 3);
                 $tables[$m->getName()] = $domaine . $bundle . ':' . str_replace('Entity\\', '', $entity);
             }
             break;
         default:
             throw ServiceException::optionValueNotSpecified($type);
             break;
     }
     return $tables;
 }
 /**
  * Execute the form builder.
  *
  * <code>
  *  $options = array(
  *             'formName'        => 'myform',
  *             'formAction'    => '/admin/acl/add/type/role',
  *             'formTitle'        => $this->container->get('translator')->trans('List Roles'),
  *             'formSubmit'    => $this->container->get('translator')->trans('Register'),
  *             'formDecorator'    => 'ElementForm.phtml',
  *             'DisplayGroup'    => true,
  *            'populate'        => array(
  *                                  'name1'    => 'Mon nom',
  *                                  'name2'    => 'Mon prénom',
  *                                  'date'    => App_Tools_Date::dayDatetime()
  *                               ),
  *    );
  *   $resultform    = $this->container->get('pi_app_admin.formbuilder_manager.model.activity')->run($options);
  * </code>
  * 
  * @param  array        $options    validator options.
  * @return string                    form builder result
  * @access public
  * @final
  *
  * @author (c) Etienne de Longeaux <*****@*****.**>
  * @since 2012-06-26
  */
 public final function execute($options)
 {
     // Chargement de l'action du formulaire.
     if (!isset($options['formAction']) || empty($options['formAction'])) {
         throw ServiceException::optionValueNotSpecified($options['formAction']);
     }
     self::$_content = $options;
     try {
         return $this->_execute();
     } catch (\Exception $e) {
         throw Service::serviceNotConfiguredCorrectly();
     }
 }
 /**
  * Factory ! We check that the requested class is a valid service.
  *
  * @param  string         $container            name of widget container.
  * @param  string         $actionName            name of action.
  * @param  array        $options            validator options.
  * @return service
  * @access public
  * @final
  * 
  * @author (c) Etienne de Longeaux <*****@*****.**>
  */
 public final function FactoryFunction($container, $actionName, $options = null)
 {
     if ($this->isServiceSupported($container, $actionName)) {
         // Gestion des options
         if (!isset($options['widget-id']) || empty($options['widget-id'])) {
             throw ServiceException::optionValueNotSpecified('widget-id', __CLASS__);
         }
         if (!isset($options['widget-lang']) || empty($options['widget-lang'])) {
             throw ServiceException::optionValueNotSpecified('widget-lang', __CLASS__);
         }
         // we set params
         $this->setParams($options);
         $method = "render" . ucfirst($this->action);
         //print_r($method);
         //print_r($this->getServiceWidget()->getAction());
         //print_r($this->action);
         //print_r($this->service);
         //print_r($container);
         //print_r($actionName);
         if (method_exists($this->serviceWidget, $method)) {
             return $this->getServiceWidget()->{$method}($options);
         } elseif (method_exists($this->serviceWidget, 'render')) {
             return $this->getServiceWidget()->run($options);
         } else {
             throw ServiceException::serviceMethodUnDefined($method);
         }
     }
 }