Example #1
0
 /**
  * Use magic stuff for generating operations
  *
  * @param $method
  * @param $arguments
  *
  * @return mixed
  */
 public function __call($method, $arguments)
 {
     if (strncmp($method, 'operationCallback', 17) === 0) {
         $operationName = substr($method, 17);
         $definition = Definition::getOperation($arguments[6], $operationName);
         $dispatcher = $GLOBALS['container']['event-dispatcher'];
         $controller = new Operation\Controller($definition, $dispatcher);
         $row = array_shift($arguments);
         $model = ModelFactory::create($arguments[5], $row['id'], $row);
         $controller->setModel($model);
         $view = new Operation\View();
         $view->setHref($arguments[0]);
         $view->setLabel($arguments[1]);
         $view->setTitle($arguments[2]);
         $view->setIcon($arguments[3]);
         $view->setAttributes($arguments[4]);
         $controller->setView($view);
         $config = array();
         $config['rootIds'] = $arguments[6];
         $config['childRecordIds'] = $arguments[7];
         $config['circularReference'] = $arguments[8];
         $config['previous'] = $arguments[9];
         $config['next'] = $arguments[10];
         $controller->setConfig($config);
         return $controller->generate();
     } elseif (strncmp($method, 'globalOperationCallback', 23) === 0) {
         $operationName = substr($method, 23);
         $definition = Definition::getGlobalOperation($arguments[5], $operationName);
         $dispatcher = $GLOBALS['container']['event-dispatcher'];
         $controller = new GlobalOperation\Controller($definition, $dispatcher);
         $view = new GlobalOperation\View();
         $view->setHref($arguments[0]);
         $view->setLabel($arguments[1]);
         $view->setTitle($arguments[2]);
         $view->setIcon($arguments[3]);
         $view->setAttributes($arguments[4]);
         $controller->setView($view);
         $config = array();
         $config['rootIds'] = $arguments[6];
         $config['childRecordIds'] = $arguments[7];
         $config['circularReference'] = $arguments[8];
         $config['previous'] = $arguments[9];
         $config['next'] = $arguments[10];
         $controller->setConfig($config);
         return $controller->generate();
     }
     return null;
 }