public function __construct()
 {
     parent::__construct();
     $this->__bar = new stdClass();
     $this->__foo_bar = new stdClass();
     $this->__foo_baz = new stdClass();
 }
Example #2
0
 /**
  * Returns the correct renderer for given attributes.
  *
  * @param string $viewName
  * @param string $templatesPath
  * @param array $requestedContentTypes
  * @return Renderer
  */
 public function getAppropriateRenderer($viewName, $templatesPath, $requestedContentTypes)
 {
     if (!$requestedContentTypes) {
         $requestedContentTypes = array();
     }
     array_push($requestedContentTypes, '*');
     // This is the catch all content type.
     foreach ($requestedContentTypes as $contentType) {
         foreach ($this->renderersList as $rendererInfo) {
             list($rendererClassName, $rendererServiceName) = $rendererInfo;
             if (call_user_func($rendererClassName . '::accepts', $viewName, $templatesPath, $contentType)) {
                 Log::debug('Using ' . $rendererClassName, 'Renderer');
                 $renderer = $this->container->getService($rendererServiceName);
                 $renderer->setTemplatesPath($templatesPath);
                 return $renderer;
             }
         }
     }
     return null;
 }
Example #3
0
 public function process()
 {
     try {
         /**
          * Session specific actions
          */
         if ($this->container->hasService('session')) {
             $this->container->session->handleUserActions();
         }
         $this->container->dispatcher->dispatch();
     } catch (Exception $e) {
         Log::fatal('Error during initialization.', 'Core', array('Exception' => get_class($e), 'message' => $e->getMessage()));
         die('<h1 class="error">' . $e->getMessage() . '</h1>');
     }
 }
 /**
  * Gets a service.
  *
  * @param  string $id The service identifier
  *
  * @return object The associated service
  *
  * @throw InvalidArgumentException if the service is not defined
  * @throw LogicException if the service has a circular reference to itself
  */
 public function getService($id)
 {
     try {
         return parent::getService($id);
     } catch (InvalidArgumentException $e) {
         if (isset($this->loading[$id])) {
             throw new LogicException(sprintf('The service "%s" has a circular reference to itself.', $id));
         }
         $definition = $this->getServiceDefinition($id);
         $this->loading[$id] = true;
         if ($definition->isShared()) {
             $service = $this->services[$id] = $this->createService($definition);
         } else {
             $service = $this->createService($definition);
         }
         unset($this->loading[$id]);
         return $service;
     }
 }
 protected function renderWindow($window)
 {
     if (is_callable($window)) {
         return call_user_func_array($window, array($this->helper));
     } elseif (is_array($window)) {
         $options = isset($window['options_param']) ? $this->serviceContainer->getParameter($window['options_param']) : array();
         if (isset($options['callback'])) {
             $window['options'] = $options;
             return call_user_func_array($window, array($this->helper));
         } else {
             $can = true;
             if (isset($options['credentials'])) {
                 $can = $this->user->can($options['credentials']);
             }
             return $can ? $this->helper->renderComponent($window['module'], $window['component'], array_merge(array('options' => $options), $window['params'])) : '';
         }
     }
     return '';
 }
Example #6
0
 /**
  * Returns the form field associated with the name (implements the ArrayAccess interface).
  *
  * @param  string $name  The offset of the value to get
  *
  * @return dmFormField   A form field instance
  */
 public function offsetGet($name)
 {
     if (!isset($this->formFields[$name])) {
         if (!($widget = $this->widgetSchema[$name])) {
             throw new InvalidArgumentException(sprintf('Widget "%s" does not exist.', $name));
         }
         if ($this->isBound) {
             $value = isset($this->taintedValues[$name]) ? $this->taintedValues[$name] : null;
         } else {
             if (isset($this->defaults[$name])) {
                 $value = $this->defaults[$name];
             } else {
                 $value = $widget instanceof sfWidgetFormSchema ? $widget->getDefaults() : $widget->getDefault();
             }
         }
         $class = $widget instanceof sfWidgetFormSchema ? 'dmFormFieldSchema' : self::$serviceContainer->getParameter('form_field.class');
         $this->formFields[$name] = new $class($widget, $this->getFormFieldSchema(), $name, $value, $this->errorSchema[$name]);
         if ($this->formFields[$name] instanceof dmFormField && ($validator = $this->getValidatorSchema()->offsetGet($name))) {
             $this->formFields[$name]->setIsRequired($validator->getOption('required'));
         }
     }
     return $this->formFields[$name];
 }
    protected function addServiceAlias($alias, $id)
    {
        $name = sfServiceContainer::camelize($alias);
        return <<<EOF

  protected function get{$name}Service()
  {
    return {$this->getServiceCall($id)};
  }

EOF;
    }
Example #8
0
 /**
  * Sets a service container parameter.
  *
  * @param string $name       The parameter name
  * @param mixed  $parameters The parameter value
  * @return dmBaseServiceContainer $this this instance
  */
 public function setParameter($name, $value)
 {
     parent::setParameter($name, $value);
     return $this;
 }
Example #9
0
 public function __construct()
 {
     parent::__construct($this->getDefaultParameters());
 }
 /**
  * Gets all service ids.
  *
  * @return array An array of all defined service ids
  */
 public function getServiceIds()
 {
     return array_unique(array_merge(array_keys($this->getServiceDefinitions()), array_keys($this->aliases), parent::getServiceIds()));
 }
 protected function getServiceCall($id)
 {
     if ('service_container' == $id) {
         return '$this';
     }
     if ($this->container->hasServiceDefinition($id)) {
         return sprintf('$this->get%sService()', sfServiceContainer::camelize($id));
     }
     return sprintf('$this->getService(\'%s\')', $id);
 }