/**
  * Load a component (tell it to parse its content)
  * @param string $componentName Name of component to load
  */
 public function loadComponent($componentName)
 {
     $component = $this->findOneBy(array('name' => $componentName));
     $this->cx->getEvents()->triggerEvent('preComponent', array('componentName' => $component->getName(), 'component' => $component, 'hook' => 'load'));
     $component->load($this->cx->getPage());
     $this->cx->getEvents()->triggerEvent('postComponent', array('componentName' => $component->getName(), 'component' => $component, 'hook' => 'load'));
 }
 /**
  * @param $cx Cx
  *
  * @throws \Cx\Core\Event\Controller\EventManagerException
  */
 public function __construct($cx)
 {
     $this->cx = $cx;
     $eventHandlerInstance = $this->cx->getEvents();
     /**
      * Loads all mediatypes into $this->allMediaTypePaths
      */
     $eventHandlerInstance->triggerEvent('mediasource.load', array($this));
     ksort($this->allMediaTypePaths);
     foreach ($this->allMediaTypePaths as $mediaSource) {
         /**
          * @var $mediaSource MediaSource
          */
         if ($mediaSource->checkAccess()) {
             $this->mediaTypePaths[$mediaSource->getName()] = $mediaSource->getDirectory();
             $this->mediaTypes[$mediaSource->getName()] = $mediaSource;
         }
     }
 }
 /**
  * PostInit hook to add entity validation
  * @param \Cx\Core\Core\Controller\Cx $cx Cx class instance
  */
 public function postInit(\Cx\Core\Core\Controller\Cx $cx)
 {
     // init cx validation
     $cx->getEvents()->addEventListener('model/onFlush', new \Cx\Core\Model\Model\Event\EntityBaseEventListener());
 }