/** * @param ServiceLocatorInterface $serviceLocator * @return \KJSencha\Service\ComponentManager */ public function createService(ServiceLocatorInterface $serviceLocator) { $serviceConfig = $this->createConfig($serviceLocator); $componentManager = new ComponentManager($serviceConfig); $componentManager->addPeeringServiceManager($serviceLocator); return $componentManager; }
/** * Component builder * * Fetches components from the ComponentManager and converts * them to a JSON format which can be read by a Ext.ComponentLoader * * When a component cannot be found or another exception occurs then a * new panel will be created which will contain the error message * * @return Response * @throws Exception */ public function componentAction() { $response = $this->getResponse(); $component = null; try { if ($componentName = $this->params()->fromPost('componentName')) { $component = $this->componentManager->get($componentName); } elseif ($componentConfig = $this->params()->fromPost('componentConfig')) { $component = $this->buildComponent(json_decode($componentConfig, true)); } } catch (Exception $e) { // When something goes wrong create a new panel which holds the error message $attributes = array('html' => 'Exception: ' . $e->getMessage(), 'bodyPadding' => 5, 'bodyStyle' => 'color: #F00; text-align: center', 'border' => 0); $component = new Ext\Panel($attributes); } $response->setContent($component->toJson()); return $response; }