Ejemplo n.º 1
0
 /**
  * @param \Enlight_Loader               $loader
  * @param \Shopware_Components_Config   $config
  * @param array                         $options
  * @return \Enlight_Class|\Zend_Mail_Transport_Abstract
  */
 public function factory(\Enlight_Loader $loader, \Shopware_Components_Config $config, array $options)
 {
     if (!isset($options['type']) && !empty($config->MailerMailer) && $config->MailerMailer != 'mail') {
         $options['type'] = $config->MailerMailer;
     }
     if (empty($options['type'])) {
         $options['type'] = 'sendmail';
     }
     if ($options['type'] == 'smtp') {
         if (!isset($options['username']) && !empty($config->MailerUsername)) {
             if (!empty($config->MailerAuth)) {
                 $options['auth'] = $config->MailerAuth;
             } elseif (empty($options['auth'])) {
                 $options['auth'] = 'login';
             }
             $options['username'] = $config->MailerUsername;
             $options['password'] = $config->MailerPassword;
         }
         if (!isset($options['ssl']) && !empty($config->MailerSMTPSecure)) {
             $options['ssl'] = $config->MailerSMTPSecure;
         }
         if (!isset($options['port']) && !empty($config->MailerPort)) {
             $options['port'] = $config->MailerPort;
         }
         if (!isset($options['name']) && !empty($config->MailerHostname)) {
             $options['name'] = $config->MailerHostname;
         }
         if (!isset($options['host']) && !empty($config->MailerHost)) {
             $options['host'] = $config->MailerHost;
         }
     }
     if (!$loader->loadClass($options['type'])) {
         $transportName = ucfirst(strtolower($options['type']));
         $transportName = 'Zend_Mail_Transport_' . $transportName;
     } else {
         $transportName = $options['type'];
     }
     unset($options['type'], $options['charset']);
     if ($transportName == 'Zend_Mail_Transport_Smtp') {
         $transport = \Enlight_Class::Instance($transportName, array($options['host'], $options));
     } elseif (!empty($options)) {
         $transport = \Enlight_Class::Instance($transportName, array($options));
     } else {
         $transport = \Enlight_Class::Instance($transportName);
     }
     /** @var $transport \Zend_Mail_Transport_Abstract */
     \Enlight_Components_Mail::setDefaultTransport($transport);
     if (!isset($options['from']) && !empty($config->Mail)) {
         $options['from'] = array('email' => $config->Mail, 'name' => $config->Shopname);
     }
     if (!empty($options['from']['email'])) {
         \Enlight_Components_Mail::setDefaultFrom($options['from']['email'], !empty($options['from']['name']) ? $options['from']['name'] : null);
     }
     if (!empty($options['replyTo']['email'])) {
         \Enlight_Components_Mail::setDefaultReplyTo($options['replyTo']['email'], !empty($options['replyTo']['name']) ? $options['replyTo']['name'] : null);
     }
     return $transport;
 }
Ejemplo n.º 2
0
 /**
  * Returns a normalized version of the reference map
  *
  * @return array
  */
 protected function _getReferenceMapNormalized()
 {
     $maps = parent::_getReferenceMapNormalized();
     foreach ($maps as $rule => $map) {
         if (isset($map[self::REF_TABLE_CLASS])) {
             $maps[$rule][self::REF_TABLE_CLASS] = Enlight_Class::getClassName($map[self::REF_TABLE_CLASS]);
         }
     }
     return $maps;
 }
Ejemplo n.º 3
0
 /**
  * @param \Enlight_Event_EventManager           $eventManager
  * @param \Shopware_Components_Snippet_Manager  $snippetManager
  * @param array                                 $options
  * @return \Enlight_Template_Manager
  */
 public function factory(\Enlight_Event_EventManager $eventManager, \Shopware_Components_Snippet_Manager $snippetManager, array $options)
 {
     /** @var $template \Enlight_Template_Manager */
     $template = \Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir(Shopware()->AppPath('Cache_Compiles'));
     $template->setCacheDir(Shopware()->AppPath('Cache_Templates'));
     $template->setTemplateDir(Shopware()->AppPath('Views'));
     $template->setOptions($options);
     $template->setEventManager($eventManager);
     $template->setTemplateDir(array('custom' => '_local', 'local' => '_local', 'emotion' => '_default', 'default' => '_default', 'base' => 'templates', 'include_dir' => '.'));
     $resource = new \Enlight_Components_Snippet_Resource($snippetManager);
     $template->registerResource('snippet', $resource);
     $template->setDefaultResourceType('snippet');
     return $template;
 }
Ejemplo n.º 4
0
 /**
  * @param \Enlight_Event_EventManager $eventManager
  * @param \Enlight_Components_Snippet_Resource $snippetResource
  * @param EscaperInterface $escaper
  * @return \Enlight_Template_Manager
  * @param array $templateConfig
  */
 public function factory(\Enlight_Event_EventManager $eventManager, \Enlight_Components_Snippet_Resource $snippetResource, EscaperInterface $escaper, array $templateConfig)
 {
     /** @var $template \Enlight_Template_Manager */
     $template = \Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir(Shopware()->AppPath('Cache_Compiles'));
     $template->setCacheDir(Shopware()->AppPath('Cache_Templates'));
     $template->setTemplateDir(Shopware()->AppPath('Views'));
     $template->setOptions($templateConfig);
     $template->setEventManager($eventManager);
     $template->registerResource('snippet', $snippetResource);
     $template->setDefaultResourceType('snippet');
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeHtml', array($escaper, 'escapeHtml'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeHtmlAttr', array($escaper, 'escapeHtmlAttr'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeJs', array($escaper, 'escapeJs'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeCss', array($escaper, 'escapeCss'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeUrl', array($escaper, 'escapeUrl'));
     return $template;
 }
Ejemplo n.º 5
0
	/**
	 * Constructor method
	 *
	 * @param unknown_type $mailRecipients
	 * @param unknown_type $mailTransport
	 */
	public function __construct($mailRecipients, $mailTransport = array())
    {
    	if(!$mailTransport instanceof Zend_Mail_Transport_Abstract) {
	    	if(empty($mailTransport['type'])) {
	    		$mailTransport['type'] = 'sendmail';
	    	}
	    	if(!Shopware()->Loader()->loadClass($mailTransport['type'])) {
				$transportName = ucfirst(strtolower($mailTransport['type']));
				$transportName = 'Zend_Mail_Transport_'.$transportName;
			}
			if($transportName=='Zend_Mail_Transport_Smtp') {
				$mailTransport = Enlight_Class::Instance($transportName, array($mailTransport['host'], $mailTransport));
			} else {
				$mailTransport = Enlight_Class::Instance($transportName, array($mailTransport));
			}
    	}
    	$this->mailTransport = $mailTransport;
    	$this->mailRecipients = explode(',', $mailRecipients);
    }
Ejemplo n.º 6
0
	/**
	 * Static function to initiate document class
	 * @param int $orderID s_order.id
	 * @param int $documentID s_core_documents.id
	 * @param array $config - configuration array, for possible values see backend\document controller
	 * @access public
	 */
	public static function initDocument($orderID, $documentID, array $config = array()) {
		if (empty($orderID)){
			$config["_preview"] = true;
		}

        /** @var $d Shopware_Components_Document */
		$d = Enlight_Class::Instance('Shopware_Components_Document');//new Shopware_Components_Document();

		//$d->setOrder(new Shopware_Models_Document_Order($orderID,$config));
		$d->setOrder(Enlight_Class::Instance('Shopware_Models_Document_Order', array($orderID,$config)));


		$d->setConfig($config);

		$d->setDocumentId($documentID);
        $d->_compatibilityMode = false;
		if (!empty($orderID)){
			$d->_subshop = Shopware()->Db()->fetchRow("
			SELECT s_core_multilanguage.id,doc_template, template, isocode,locale FROM s_order,s_core_multilanguage WHERE s_order.subshopID = s_core_multilanguage.id AND s_order.id = ?
			",array($orderID));

			if (empty($d->_subshop["doc_template"])) $d->setTemplate($d->_defaultPath);

			if (empty($d->_subshop["id"])){
				throw new Enlight_Exception("Could not load template path for order $orderID");
			}


		}else {

			$d->_subshop = Shopware()->Db()->fetchRow("
			SELECT s_core_multilanguage.id,doc_template, template, isocode,locale FROM s_core_multilanguage WHERE s_core_multilanguage.default = 1
			");

            $d->setTemplate($d->_defaultPath);
            $d->_subshop["doc_template"] = $d->_defaultPath;



		}

		$d->initTemplateEngine();

		return $d;
	}
Ejemplo n.º 7
0
 /**
  * Reset all instances, resources and init the internal view, template and front properties
  */
 public function reset()
 {
     $this->resetRequest();
     $this->resetResponse();
     $this->_view = null;
     $this->_template = null;
     $this->_front = null;
     Enlight_Application::Instance()->Plugins()->reset();
     //Enlight_Application::Instance()->Hooks()->resetHooks();
     Enlight_Application::Instance()->Events()->reset();
     //Enlight_Application::Instance()->Db()->getProfiler()->clear();
     $resources = array('Plugins' => 'Enlight_Plugin_PluginManager', 'Template' => 'Enlight_Template_Manager', 'Front' => 'Enlight_Controller_Front', 'Enlight_Controller_Plugins_ErrorHandler_Bootstrap', 'Enlight_Controller_Plugins_ViewRenderer_Bootstrap');
     foreach ($resources as $resource => $class) {
         Enlight_Class::resetInstance($class);
         if (!is_int($resource)) {
             Enlight_Application::Instance()->Bootstrap()->resetResource($resource)->loadResource($resource);
         }
     }
     Enlight_Application::Instance()->Bootstrap()->resetResource('System')->resetResource('Modules')->resetResource('Config')->resetResource('Shop');
 }
Ejemplo n.º 8
0
    /**
     * Init mail transport
     *
     * @return Zend_Mail_Transport_Abstract
     */
    protected function initMailTransport()
    {
        $options = Shopware()->getOption('mail') ? Shopware()->getOption('mail') : array();
        $config = $this->getResource('Config');

        if (!isset($options['type']) && !empty($config->MailerMailer) && $config->MailerMailer!='mail') {
            $options['type'] = $config->MailerMailer;
        }
        if (empty($options['type'])) {
            $options['type'] = 'sendmail';
        }

        if ($options['type'] == 'smtp') {
            if (!isset($options['username']) && !empty($config->MailerUsername)) {
                if (!empty($config->MailerAuth)) {
                    $options['auth'] = $config->MailerAuth;
                } elseif (empty($options['auth'])) {
                    $options['auth'] = 'login';
                }
                $options['username'] = $config->MailerUsername;
                $options['password'] = $config->MailerPassword;
            }
            if (!isset($options['ssl']) && !empty($config->MailerSMTPSecure)) {
                $options['ssl'] = $config->MailerSMTPSecure;
            }
            if (!isset($options['port']) && !empty($config->MailerPort)) {
                $options['port'] = $config->MailerPort;
            }
            if (!isset($options['name']) && !empty($config->MailerHostname)) {
                $options['name'] = $config->MailerHostname;
            }
            if (!isset($options['host']) && !empty($config->MailerHost)) {
                $options['host'] = $config->MailerHost;
            }
        }

        if (!Shopware()->Loader()->loadClass($options['type'])) {
            $transportName = ucfirst(strtolower($options['type']));
            $transportName = 'Zend_Mail_Transport_'.$transportName;
        } else {
            $transportName = $options['type'];
        }
        unset($options['type'], $options['charset']);

        if ($transportName=='Zend_Mail_Transport_Smtp') {
            $transport = Enlight_Class::Instance($transportName, array($options['host'], $options));
        } elseif (!empty($options)) {
            $transport = Enlight_Class::Instance($transportName, array($options));
        } else {
            $transport = Enlight_Class::Instance($transportName);
        }
        Enlight_Components_Mail::setDefaultTransport($transport);

        if (!isset($options['from']) && !empty($config->Mail)) {
            $options['from'] = array('email'=>$config->Mail, 'name'=>$config->Shopname);
        }

        if (!empty($options['from']['email'])) {
            Enlight_Components_Mail::setDefaultFrom(
                $options['from']['email'],
                !empty($options['from']['name']) ? $options['from']['name'] : null
            );
        }
        if (!empty($options['replyTo']['email'])) {
            Enlight_Components_Mail::setDefaultReplyTo(
                $options['replyTo']['email'],
                !empty($options['replyTo']['name']) ? $options['replyTo']['name'] : null
            );
        }

        return $transport;
    }
Ejemplo n.º 9
0
 /**
  * Generates an instances of an import resource
  *
  * @param $name
  * @param $progress
  * @param $source
  * @param $target
  * @param $request
  * @return Shopware_Components_Migration_Import_Resource_Abstract
  */
 public static function resourceFactory($name, $progress, $source, $target, $request)
 {
     /** @var $import Shopware_Components_Migration_Import_Resource_Abstract */
     $className = self::$resourceNamespace . '_' . $name;
     $import = Enlight_Class::Instance($className, [$progress, $source, $target, $request]);
     return $import;
 }
Ejemplo n.º 10
0
 /**
  * The init template method instantiates the Enlight_Template_Manager
  * and sets the cache, template and compile directory into the manager.
  * After the directories has been set, the template configuration is set
  * by the internal config array.
  *
  * @return Enlight_Template_Manager
  */
 protected function initTemplate()
 {
     /** @var $template Enlight_Template_Manager */
     $template = Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir($this->Application()->AppPath('Cache_Compiles'));
     $template->setCacheDir($this->Application()->AppPath('Cache_Templates'));
     $template->setTemplateDir($this->Application()->AppPath('Views'));
     $config = $this->Application()->getOption('template');
     if ($config !== null) {
         foreach ($config as $key => $value) {
             $template->{'set' . $key}($value);
         }
     }
     return $template;
 }
Ejemplo n.º 11
0
 /**
  * The init template method instantiates the Enlight_Template_Manager
  * and sets the cache, template and compile directory into the manager.
  * After the directories has been set, the template configuration is set
  * by the internal config array.
  *
  * @return Enlight_Template_Manager
  */
 protected function initTemplate()
 {
     /** @var $template Enlight_Template_Manager */
     $template = Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir($this->Application()->AppPath('Cache_Compiles'));
     $template->setCacheDir($this->Application()->AppPath('Cache_Templates'));
     $template->setTemplateDir($this->Application()->AppPath('Views'));
     $config = $this->Application()->getOption('template');
     $template->setOptions($config);
     return $template;
 }
Ejemplo n.º 12
0
 /**
  * Returns the class name of the given table
  *
  * @param string $tableName
  * @return Zend_Db_Table_Abstract
  */
 protected function _getTableFromString($tableName)
 {
     $tableName = Enlight_Class::getClassName($tableName);
     return parent::_getTableFromString($tableName);
 }
Ejemplo n.º 13
0
 /**
  * @return DataTransformerFactory
  */
 public function getDataTransformerFactory()
 {
     if ($this->dataTransformerFactory === null) {
         $this->dataTransformerFactory = Enlight_Class::Instance('Shopware\\Components\\SwagImportExport\\Factories\\DataTransformerFactory');
     }
     return $this->dataTransformerFactory;
 }
Ejemplo n.º 14
0
 /**
  * Returns a mock object for the specified class.
  *
  * @param  string  $originalClassName
  * @param  array   $methods
  * @param  array   $arguments
  * @param  string  $mockClassName
  * @param  boolean $callOriginalConstructor
  * @param  boolean $callOriginalClone
  * @param  boolean $callAutoload
  * @return PHPUnit_Framework_MockObject_MockObject
  * @throws InvalidArgumentException
  * @since  Method available since Release 3.0.0
  */
 public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true)
 {
     $originalClassName = Enlight_Class::getClassName($originalClassName);
     return parent::getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload);
 }
Ejemplo n.º 15
0
 /**
  * The Enlight_Plugin_PluginCollection class constructor initials the internal plugin list.
  */
 public function __construct()
 {
     $this->plugins = new ArrayObject();
     parent::__construct();
 }
Ejemplo n.º 16
0
 /**
  * The Enlight_Plugin_Bootstrap expects a name for the plugin and
  * optionally an instance of the Enlight_Plugin_PluginCollection
  *
  * @param $name
  * @param Enlight_Plugin_PluginCollection $collection
  */
 public function __construct($name, $collection = null)
 {
     $this->name = (string) $name;
     $this->setCollection($collection);
     parent::__construct();
 }
Ejemplo n.º 17
0
 /**
  * Plugin event listener function which is fired
  * when the top seller resource has to be initialed.
  * @return Shopware_Components_TopSeller
  */
 public function initTopSellerResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $topSeller = Enlight_Class::Instance('Shopware_Components_TopSeller');
     $this->Application()->Bootstrap()->registerResource('TopSeller', $topSeller);
     return $topSeller;
 }
Ejemplo n.º 18
0
 /**
  * Returns the instance of the application bootstrap
  *
  * @return Enlight_Bootstrap
  */
 public function Bootstrap()
 {
     if (!$this->_bootstrap) {
         $class = $this->App() . '_Bootstrap';
         $this->_bootstrap = Enlight_Class::Instance($class, array($this));
     }
     return $this->_bootstrap;
 }
Ejemplo n.º 19
0
 /**
  * @param Enlight_Event_EventManager $eventManager
  */
 public function __construct(Enlight_Event_EventManager $eventManager)
 {
     $this->eventManager = $eventManager;
     parent::__construct();
 }
Ejemplo n.º 20
0
 /**
  * @return Shopware_Components_CustomerInformationHandler
  */
 public function onInitCustomerInformationHandlerResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $customerInformationHandler = Enlight_Class::Instance('Shopware_Components_CustomerInformationHandler');
     $this->getShopwareBootstrap()->registerResource('CustomerInformationHandler', $customerInformationHandler);
     return $customerInformationHandler;
 }
Ejemplo n.º 21
0
 /**
  * Static function to initiate document class
  * @param  int                           $orderID    s_order.id
  * @param  int                           $documentID s_core_documents.id
  * @param  array                         $config     - configuration array, for possible values see backend\document controller
  * @throws Enlight_Exception
  * @return \Shopware_Components_Document
  */
 public static function initDocument($orderID, $documentID, array $config = array())
 {
     if (empty($orderID)) {
         $config["_preview"] = true;
     }
     /** @var $document Shopware_Components_Document */
     $document = Enlight_Class::Instance('Shopware_Components_Document');
     //new Shopware_Components_Document();
     //$d->setOrder(new Shopware_Models_Document_Order($orderID,$config));
     $document->setOrder(Enlight_Class::Instance('Shopware_Models_Document_Order', array($orderID, $config)));
     $document->setConfig($config);
     $document->setDocumentId($documentID);
     if (!empty($orderID)) {
         $document->_subshop = Shopware()->Db()->fetchRow("\n                SELECT\n                    s.id,\n                    m.document_template_id as doc_template_id,\n                    m.template_id as template_id,\n                    (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.document_template_id) as doc_template,\n                    (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.template_id) as template,\n                    s.id as isocode,\n                    s.locale_id as locale\n                FROM s_order, s_core_shops s\n                LEFT JOIN s_core_shops m\n                    ON m.id=s.main_id\n                    OR (s.main_id IS NULL AND m.id=s.id)\n                WHERE s_order.language = s.id\n                AND s_order.id = ?\n                ", array($orderID));
         if (empty($document->_subshop["doc_template"])) {
             $document->setTemplate($document->_defaultPath);
         }
         if (empty($document->_subshop["id"])) {
             throw new Enlight_Exception("Could not load template path for order {$orderID}");
         }
     } else {
         $document->_subshop = Shopware()->Db()->fetchRow("\n            SELECT\n                s.id,\n                s.document_template_id as doc_template_id,\n                s.template_id,\n                (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.document_template_id) as doc_template,\n                (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.template_id) as template,\n                s.id as isocode,\n                s.locale_id as locale\n            FROM s_core_shops s\n            WHERE s.default = 1\n            ");
         $document->setTemplate($document->_defaultPath);
         $document->_subshop["doc_template"] = $document->_defaultPath;
     }
     $document->setTranslationComponent();
     $document->initTemplateEngine();
     return $document;
 }
Ejemplo n.º 22
0
 /**
  * Plugin event listener function which is fired
  * when the also bought resource has to be initialed.
  *
  * @return Shopware_Components_SeoIndex
  */
 public function initSeoIndexResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $seoIndex = Enlight_Class::Instance('Shopware_Components_SeoIndex');
     return $seoIndex;
 }
Ejemplo n.º 23
0
 /**
  * The Enlight_Plugin_Bootstrap expects a name for the plugin and
  * optionally an instance of the Enlight_Plugin_PluginCollection
  *
  * @param $name
  */
 public function __construct($name)
 {
     $this->name = (string) $name;
     parent::__construct();
 }
 public function __construct()
 {
     parent::__construct();
     $this->modelManager = Shopware()->Models();
 }
Ejemplo n.º 25
0
 /**
  * Magic caller method
  *
  * @param string $name
  * @param array  $value
  * @return mixed
  */
 public function __call($name, $value = null)
 {
     if ('Action' == substr($name, -6)) {
         $action = substr($name, 0, strlen($name) - 6);
         throw new Enlight_Controller_Exception('Action "' . $this->controller_name . '_' . $name . '" not found failure', Enlight_Controller_Exception::ActionNotFound);
     }
     return parent::__call($name, $value);
 }
Ejemplo n.º 26
-1
 /**
  * Loads the Zend resource and initials the Enlight_Controller_Front class.
  * After the front resource is loaded, the controller path is added to the
  * front dispatcher. After the controller path is set to the dispatcher,
  * the plugin namespace of the front resource is set.
  *
  * @param Container $container
  * @param \Shopware_Bootstrap $bootstrap
  * @param \Enlight_Event_EventManager $eventManager
  * @param array $options
  * @throws \Exception
  * @return \Enlight_Controller_Front
  */
 public function factory(Container $container, \Shopware_Bootstrap $bootstrap, \Enlight_Event_EventManager $eventManager, array $options)
 {
     /** @var $front \Enlight_Controller_Front */
     $front = \Enlight_Class::Instance('Enlight_Controller_Front', array($eventManager));
     $front->setDispatcher($container->get('Dispatcher'));
     $front->Dispatcher()->addModuleDirectory(Shopware()->AppPath('Controllers'));
     $front->setRouter($container->get('Router'));
     $front->setParams($options);
     /** @var $plugins  \Enlight_Plugin_PluginManager */
     $plugins = $container->get('Plugins');
     $plugins->registerNamespace($front->Plugins());
     $front->setParam('bootstrap', $bootstrap);
     if (!empty($options['throwExceptions'])) {
         $front->throwExceptions((bool) $options['throwExceptions']);
     }
     try {
         $container->load('Cache');
         $container->load('Db');
         $container->load('Plugins');
     } catch (\Exception $e) {
         if ($front->throwExceptions()) {
             throw $e;
         }
         $front->Response()->setException($e);
     }
     return $front;
 }