Ejemplo n.º 1
0
 /**
  * Retrieves singleton object
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @return IfwPsn_Wp_Options
  */
 public static function getInstance(IfwPsn_Wp_Plugin_Manager $pm)
 {
     if (!isset(self::$_instances[$pm->getAbbr()])) {
         self::$_instances[$pm->getAbbr()] = new self($pm);
     }
     return self::$_instances[$pm->getAbbr()];
 }
Ejemplo n.º 2
0
 /**
  * Inits default logic
  */
 public function init()
 {
     // check if module properties are set
     $this->_checkProperties();
     // register lib
     if ($this->_pathinfo->hasRootLib()) {
         // add the module lib dir to the autoloader
         $classPrefix = $this->_pm->getAbbr() . '_Module_' . $this->_pathinfo->getDirname();
         IfwPsn_Wp_Autoloader::registerModule($classPrefix, $this->_pathinfo->getRootLib());
     }
     // register templates dir
     if ($this->_pm->getAccess()->isPlugin()) {
         $this->initTpl();
     }
     // init module translation
     $this->_initTranslation();
     // load default script and style files
     if ($this->_pm->getAccess()->isPlugin() && !$this->_pm->getAccess()->isAjax()) {
         $this->_enqueueScripts();
     }
     if ($this->_pm->getAccess()->isAjax() && !$this->_pm->getAccess()->isHeartbeat()) {
         $this->_initAjax();
     }
     $this->_initialized = true;
 }
Ejemplo n.º 3
0
 public function loadPluginManager()
 {
     require_once IFW_PSN_LIB_ROOT . '/IfwPsn/Wp/Plugin/Manager.php';
     $customAbbr = isset($this->_config->plugin->customAbbr) ? $this->_config->plugin->customAbbr : null;
     $this->_pm = IfwPsn_Wp_Plugin_Manager::init($this->_pluginPathinfo, $customAbbr);
     $this->_pm->getLogger()->log($this->_pm->getAbbr() . ': Pluginmanager loaded.');
 }
Ejemplo n.º 4
0
 /**
  * @return bool
  * @throws IfwPsn_Wp_Module_Exception
  */
 public function isValid()
 {
     if (!$this->hasBootstrap()) {
         throw new IfwPsn_Wp_Module_Exception('Bootstrap file not found.');
     }
     $expectedClassname = $this->getDirname() . '_Bootstrap';
     $bootstrap = $this->getBootstrap();
     if (!in_array($expectedClassname, $this->_getClasses($bootstrap))) {
         throw new IfwPsn_Wp_Module_Exception('Bootstrap class is not valid. Expected: ' . $expectedClassname);
     }
     if (strstr(get_class($this), 'IfwPsn_') === false) {
         $classHeaderFormat = 'class %s extends Ifw' . $this->_pm->getAbbr() . '_Wp_Module_Bootstrap_Abstract';
     } else {
         $classHeaderFormat = 'class %s extends IfwPsn_Wp_Module_Bootstrap_Abstract';
     }
     $expectedClassHeader = sprintf($classHeaderFormat, $expectedClassname);
     if (strstr($bootstrap, $expectedClassHeader) === false) {
         throw new IfwPsn_Wp_Module_Exception('Bootstrap class header is not valid. Expected: "' . $expectedClassHeader . '"');
     }
     return true;
 }
Ejemplo n.º 5
0
 /**
  * Factorys the plugin bootstrap class
  *
  * @param IfwPsn_Wp_Plugin_Manager $pm the plugin manager
  * @throws IfwPsn_Wp_Plugin_Exception
  * @return IfwPsn_Wp_Plugin_Bootstrap_Abstract
  */
 public static function factory(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $bootstrapClass = $pm->getAbbr() . '_Bootstrap';
     $bootstrapFile = $pm->getPathinfo()->getRoot() . 'bootstrap.php';
     if ((require_once $bootstrapFile) == false) {
         throw new IfwPsn_Wp_Plugin_Exception('Bootstrap class ' . $bootstrapClass . ' not found');
     }
     $bootstrap = new $bootstrapClass($pm);
     if (!$bootstrap instanceof IfwPsn_Wp_Plugin_Bootstrap_Abstract) {
         throw new IfwPsn_Wp_Plugin_Exception('Bootstrap class ' . $bootstrapClass . ' must extend IfwPsn_Wp_Plugin_Bootstrap_Abstract');
     }
     return $bootstrap;
 }
Ejemplo n.º 6
0
 /**
  * @param $module
  * @return string
  */
 protected function _getModuleClassName($module)
 {
     return $this->_pm->getAbbr() . '_' . $module . '_Bootstrap';
 }
Ejemplo n.º 7
0
 /**
  * Retrieves custom controller name
  *  
  * @param IfwPsn_Vendor_Zend_Controller_Request_Abstract $request
  * @return string|boolean
  */
 protected function _getCustomController($request)
 {
     $controllerName = $this->_pm->getAbbr() . '-' . $request->get('controller');
     return $controllerName;
 }
Ejemplo n.º 8
0
 /**
  * Writes log entry with plugin abbreviation prefix
  *
  * @param $message
  * @param null $priority
  * @param null $extras
  */
 public function logPrefixed($message, $priority = null, $extras = null)
 {
     $message = $this->_pm->getAbbr() . ': ' . $message;
     $this->log($message, $priority, $extras);
 }
Ejemplo n.º 9
0
 /**
  * Retrieves a Twig environment with filesystem loader
  *
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @param array $twigOptions
  * @param null $instanceToken
  * @return IfwPsn_Vendor_Twig_Environment
  * @throws IfwPsn_Wp_Exception
  */
 public static function getFilesytemInstance(IfwPsn_Wp_Plugin_Manager $pm, $twigOptions = array(), $instanceToken = null)
 {
     $options = array('twig_loader' => 'Filesystem', 'plugin_manager' => $pm);
     if (!empty($twigOptions) && is_array($twigOptions)) {
         $options['twig_options'] = $twigOptions;
     }
     if (is_null($instanceToken)) {
         $instanceToken = $options['twig_loader'];
     }
     if (!isset(self::$_instances[$pm->getAbbr()][$instanceToken])) {
         self::$_instances[$pm->getAbbr()][$instanceToken] = self::factory($options);
     }
     return self::$_instances[$pm->getAbbr()][$instanceToken];
 }