@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return array( |
| 4 | - 'name' => 'ai-client-html', |
|
| 5 | - 'depends' => array( |
|
| 6 | - 'aimeos-core', |
|
| 7 | - 'ai-controller-jobs', |
|
| 8 | - ), |
|
| 9 | - 'include' => array( |
|
| 10 | - 'client/html/src', |
|
| 11 | - 'controller/jobs/src', |
|
| 12 | - ), |
|
| 13 | - 'i18n' => array( |
|
| 14 | - 'client' => 'client/i18n', |
|
| 15 | - 'client/code' => 'client/i18n/code', |
|
| 16 | - 'client/country' => 'client/i18n/country', |
|
| 17 | - 'client/currency' => 'client/i18n/currency', |
|
| 18 | - 'client/language' => 'client/i18n/language', |
|
| 19 | - ), |
|
| 20 | - 'config' => array( |
|
| 21 | - 'client/html/config', |
|
| 22 | - ), |
|
| 23 | - 'custom' => array( |
|
| 24 | - 'client/html/templates' => array( |
|
| 25 | - 'client/html/templates', |
|
| 26 | - ), |
|
| 27 | - 'controller/jobs' => array( |
|
| 28 | - 'controller/jobs/src', |
|
| 29 | - ), |
|
| 30 | - ), |
|
| 4 | + 'name' => 'ai-client-html', |
|
| 5 | + 'depends' => array( |
|
| 6 | + 'aimeos-core', |
|
| 7 | + 'ai-controller-jobs', |
|
| 8 | + ), |
|
| 9 | + 'include' => array( |
|
| 10 | + 'client/html/src', |
|
| 11 | + 'controller/jobs/src', |
|
| 12 | + ), |
|
| 13 | + 'i18n' => array( |
|
| 14 | + 'client' => 'client/i18n', |
|
| 15 | + 'client/code' => 'client/i18n/code', |
|
| 16 | + 'client/country' => 'client/i18n/country', |
|
| 17 | + 'client/currency' => 'client/i18n/currency', |
|
| 18 | + 'client/language' => 'client/i18n/language', |
|
| 19 | + ), |
|
| 20 | + 'config' => array( |
|
| 21 | + 'client/html/config', |
|
| 22 | + ), |
|
| 23 | + 'custom' => array( |
|
| 24 | + 'client/html/templates' => array( |
|
| 25 | + 'client/html/templates', |
|
| 26 | + ), |
|
| 27 | + 'controller/jobs' => array( |
|
| 28 | + 'controller/jobs/src', |
|
| 29 | + ), |
|
| 30 | + ), |
|
| 31 | 31 | ); |
@@ -19,141 +19,141 @@ |
||
| 19 | 19 | * @subpackage Order |
| 20 | 20 | */ |
| 21 | 21 | class Factory |
| 22 | - extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Creates a new controller specified by the given name. |
|
| 27 | - * |
|
| 28 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | - * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | - * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | - * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | - */ |
|
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | - { |
|
| 35 | - /** controller/jobs/order/email/payment/name |
|
| 36 | - * Class name of the used order email payment scheduler controller implementation |
|
| 37 | - * |
|
| 38 | - * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | - * To use this implementation, you have to set the last part of the class |
|
| 40 | - * name as configuration value so the controller factory knows which class it |
|
| 41 | - * has to instantiate. |
|
| 42 | - * |
|
| 43 | - * For example, if the name of the default class is |
|
| 44 | - * |
|
| 45 | - * \Aimeos\Controller\Jobs\Order\Email\Payment\Standard |
|
| 46 | - * |
|
| 47 | - * and you want to replace it with your own version named |
|
| 48 | - * |
|
| 49 | - * \Aimeos\Controller\Jobs\Order\Email\Payment\Mypayment |
|
| 50 | - * |
|
| 51 | - * then you have to set the this configuration option: |
|
| 52 | - * |
|
| 53 | - * controller/jobs/order/email/payment/name = Mypayment |
|
| 54 | - * |
|
| 55 | - * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | - * so take care that the configuration value is exactly named like the last |
|
| 57 | - * part of the class name. |
|
| 58 | - * |
|
| 59 | - * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | - * characters are possible! You should always start the last part of the class |
|
| 61 | - * name with an upper case character and continue only with lower case characters |
|
| 62 | - * or numbers. Avoid chamel case names like "MyPayment"! |
|
| 63 | - * |
|
| 64 | - * @param string Last part of the class name |
|
| 65 | - * @since 2014.03 |
|
| 66 | - * @category Developer |
|
| 67 | - */ |
|
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/order/email/payment/name', 'Standard' ); |
|
| 70 | - } |
|
| 25 | + /** |
|
| 26 | + * Creates a new controller specified by the given name. |
|
| 27 | + * |
|
| 28 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | + * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | + * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | + * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | + */ |
|
| 33 | + public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | + { |
|
| 35 | + /** controller/jobs/order/email/payment/name |
|
| 36 | + * Class name of the used order email payment scheduler controller implementation |
|
| 37 | + * |
|
| 38 | + * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | + * To use this implementation, you have to set the last part of the class |
|
| 40 | + * name as configuration value so the controller factory knows which class it |
|
| 41 | + * has to instantiate. |
|
| 42 | + * |
|
| 43 | + * For example, if the name of the default class is |
|
| 44 | + * |
|
| 45 | + * \Aimeos\Controller\Jobs\Order\Email\Payment\Standard |
|
| 46 | + * |
|
| 47 | + * and you want to replace it with your own version named |
|
| 48 | + * |
|
| 49 | + * \Aimeos\Controller\Jobs\Order\Email\Payment\Mypayment |
|
| 50 | + * |
|
| 51 | + * then you have to set the this configuration option: |
|
| 52 | + * |
|
| 53 | + * controller/jobs/order/email/payment/name = Mypayment |
|
| 54 | + * |
|
| 55 | + * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | + * so take care that the configuration value is exactly named like the last |
|
| 57 | + * part of the class name. |
|
| 58 | + * |
|
| 59 | + * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | + * characters are possible! You should always start the last part of the class |
|
| 61 | + * name with an upper case character and continue only with lower case characters |
|
| 62 | + * or numbers. Avoid chamel case names like "MyPayment"! |
|
| 63 | + * |
|
| 64 | + * @param string Last part of the class name |
|
| 65 | + * @since 2014.03 |
|
| 66 | + * @category Developer |
|
| 67 | + */ |
|
| 68 | + if( $name === null ) { |
|
| 69 | + $name = $context->getConfig()->get( 'controller/jobs/order/email/payment/name', 'Standard' ); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 73 | - { |
|
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | - } |
|
| 72 | + if( ctype_alnum( $name ) === false ) |
|
| 73 | + { |
|
| 74 | + $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name; |
|
| 78 | + $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 82 | 82 | |
| 83 | - /** controller/jobs/order/email/payment/decorators/excludes |
|
| 84 | - * Excludes decorators added by the "common" option from the order email payment controllers |
|
| 85 | - * |
|
| 86 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | - * modify what is returned to the caller. |
|
| 90 | - * |
|
| 91 | - * This option allows you to remove a decorator added via |
|
| 92 | - * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | - * around the job controller. |
|
| 94 | - * |
|
| 95 | - * controller/jobs/order/email/payment/decorators/excludes = array( 'decorator1' ) |
|
| 96 | - * |
|
| 97 | - * This would remove the decorator named "decorator1" from the list of |
|
| 98 | - * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | - * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | - * |
|
| 101 | - * @param array List of decorator names |
|
| 102 | - * @since 2015.09 |
|
| 103 | - * @category Developer |
|
| 104 | - * @see controller/jobs/common/decorators/default |
|
| 105 | - * @see controller/jobs/order/email/payment/decorators/global |
|
| 106 | - * @see controller/jobs/order/email/payment/decorators/local |
|
| 107 | - */ |
|
| 83 | + /** controller/jobs/order/email/payment/decorators/excludes |
|
| 84 | + * Excludes decorators added by the "common" option from the order email payment controllers |
|
| 85 | + * |
|
| 86 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | + * modify what is returned to the caller. |
|
| 90 | + * |
|
| 91 | + * This option allows you to remove a decorator added via |
|
| 92 | + * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | + * around the job controller. |
|
| 94 | + * |
|
| 95 | + * controller/jobs/order/email/payment/decorators/excludes = array( 'decorator1' ) |
|
| 96 | + * |
|
| 97 | + * This would remove the decorator named "decorator1" from the list of |
|
| 98 | + * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | + * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | + * |
|
| 101 | + * @param array List of decorator names |
|
| 102 | + * @since 2015.09 |
|
| 103 | + * @category Developer |
|
| 104 | + * @see controller/jobs/common/decorators/default |
|
| 105 | + * @see controller/jobs/order/email/payment/decorators/global |
|
| 106 | + * @see controller/jobs/order/email/payment/decorators/local |
|
| 107 | + */ |
|
| 108 | 108 | |
| 109 | - /** controller/jobs/order/email/payment/decorators/global |
|
| 110 | - * Adds a list of globally available decorators only to the order email payment controllers |
|
| 111 | - * |
|
| 112 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | - * modify what is returned to the caller. |
|
| 116 | - * |
|
| 117 | - * This option allows you to wrap global decorators |
|
| 118 | - * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | - * |
|
| 120 | - * controller/jobs/order/email/payment/decorators/global = array( 'decorator1' ) |
|
| 121 | - * |
|
| 122 | - * This would add the decorator named "decorator1" defined by |
|
| 123 | - * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | - * |
|
| 125 | - * @param array List of decorator names |
|
| 126 | - * @since 2015.09 |
|
| 127 | - * @category Developer |
|
| 128 | - * @see controller/jobs/common/decorators/default |
|
| 129 | - * @see controller/jobs/order/email/payment/decorators/excludes |
|
| 130 | - * @see controller/jobs/order/email/payment/decorators/local |
|
| 131 | - */ |
|
| 109 | + /** controller/jobs/order/email/payment/decorators/global |
|
| 110 | + * Adds a list of globally available decorators only to the order email payment controllers |
|
| 111 | + * |
|
| 112 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | + * modify what is returned to the caller. |
|
| 116 | + * |
|
| 117 | + * This option allows you to wrap global decorators |
|
| 118 | + * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | + * |
|
| 120 | + * controller/jobs/order/email/payment/decorators/global = array( 'decorator1' ) |
|
| 121 | + * |
|
| 122 | + * This would add the decorator named "decorator1" defined by |
|
| 123 | + * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | + * |
|
| 125 | + * @param array List of decorator names |
|
| 126 | + * @since 2015.09 |
|
| 127 | + * @category Developer |
|
| 128 | + * @see controller/jobs/common/decorators/default |
|
| 129 | + * @see controller/jobs/order/email/payment/decorators/excludes |
|
| 130 | + * @see controller/jobs/order/email/payment/decorators/local |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | - /** controller/jobs/order/email/payment/decorators/local |
|
| 134 | - * Adds a list of local decorators only to the order email payment controllers |
|
| 135 | - * |
|
| 136 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | - * modify what is returned to the caller. |
|
| 140 | - * |
|
| 141 | - * This option allows you to wrap local decorators |
|
| 142 | - * ("\Aimeos\Controller\Jobs\Order\Email\Payment\Decorator\*") around this job controller. |
|
| 143 | - * |
|
| 144 | - * controller/jobs/order/email/payment/decorators/local = array( 'decorator2' ) |
|
| 145 | - * |
|
| 146 | - * This would add the decorator named "decorator2" defined by |
|
| 147 | - * "\Aimeos\Controller\Jobs\Order\Email\Payment\Decorator\Decorator2" only to this job |
|
| 148 | - * controller. |
|
| 149 | - * |
|
| 150 | - * @param array List of decorator names |
|
| 151 | - * @since 2015.09 |
|
| 152 | - * @category Developer |
|
| 153 | - * @see controller/jobs/common/decorators/default |
|
| 154 | - * @see controller/jobs/order/email/payment/decorators/excludes |
|
| 155 | - * @see controller/jobs/order/email/payment/decorators/global |
|
| 156 | - */ |
|
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/payment' ); |
|
| 158 | - } |
|
| 133 | + /** controller/jobs/order/email/payment/decorators/local |
|
| 134 | + * Adds a list of local decorators only to the order email payment controllers |
|
| 135 | + * |
|
| 136 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | + * modify what is returned to the caller. |
|
| 140 | + * |
|
| 141 | + * This option allows you to wrap local decorators |
|
| 142 | + * ("\Aimeos\Controller\Jobs\Order\Email\Payment\Decorator\*") around this job controller. |
|
| 143 | + * |
|
| 144 | + * controller/jobs/order/email/payment/decorators/local = array( 'decorator2' ) |
|
| 145 | + * |
|
| 146 | + * This would add the decorator named "decorator2" defined by |
|
| 147 | + * "\Aimeos\Controller\Jobs\Order\Email\Payment\Decorator\Decorator2" only to this job |
|
| 148 | + * controller. |
|
| 149 | + * |
|
| 150 | + * @param array List of decorator names |
|
| 151 | + * @since 2015.09 |
|
| 152 | + * @category Developer |
|
| 153 | + * @see controller/jobs/common/decorators/default |
|
| 154 | + * @see controller/jobs/order/email/payment/decorators/excludes |
|
| 155 | + * @see controller/jobs/order/email/payment/decorators/global |
|
| 156 | + */ |
|
| 157 | + return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/payment' ); |
|
| 158 | + } |
|
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string|null $name Name of the controller or "Standard" if null |
| 31 | 31 | * @return \Aimeos\Controller\Jobs\Iface New controller object |
| 32 | 32 | */ |
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 33 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) |
|
| 34 | 34 | { |
| 35 | 35 | /** controller/jobs/order/email/payment/name |
| 36 | 36 | * Class name of the used order email payment scheduler controller implementation |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | * @since 2014.03 |
| 66 | 66 | * @category Developer |
| 67 | 67 | */ |
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/order/email/payment/name', 'Standard' ); |
|
| 68 | + if ($name === null) { |
|
| 69 | + $name = $context->getConfig()->get('controller/jobs/order/email/payment/name', 'Standard'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 72 | + if (ctype_alnum($name) === false) |
|
| 73 | 73 | { |
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 74 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\'.$name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\' . $name; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Payment\\'.$name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); |
|
| 82 | 82 | |
| 83 | 83 | /** controller/jobs/order/email/payment/decorators/excludes |
| 84 | 84 | * Excludes decorators added by the "common" option from the order email payment controllers |
@@ -154,6 +154,6 @@ discard block |
||
| 154 | 154 | * @see controller/jobs/order/email/payment/decorators/excludes |
| 155 | 155 | * @see controller/jobs/order/email/payment/decorators/global |
| 156 | 156 | */ |
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/payment' ); |
|
| 157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'order/email/payment'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -19,168 +19,168 @@ |
||
| 19 | 19 | * @subpackage Order |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Controller\Jobs\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Returns the localized name of the job. |
|
| 27 | - * |
|
| 28 | - * @return string Name of the job |
|
| 29 | - */ |
|
| 30 | - public function getName() |
|
| 31 | - { |
|
| 32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order payment related e-mails' ); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Returns the localized description of the job. |
|
| 38 | - * |
|
| 39 | - * @return string Description of the job |
|
| 40 | - */ |
|
| 41 | - public function getDescription() |
|
| 42 | - { |
|
| 43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order confirmation or payment status update e-mails' ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Executes the job. |
|
| 49 | - * |
|
| 50 | - * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 51 | - */ |
|
| 52 | - public function run() |
|
| 53 | - { |
|
| 54 | - $aimeos = $this->getAimeos(); |
|
| 55 | - $context = $this->getContext(); |
|
| 56 | - $config = $context->getConfig(); |
|
| 57 | - $mailer = $context->getMail(); |
|
| 58 | - $view = $context->getView(); |
|
| 59 | - |
|
| 60 | - $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 61 | - |
|
| 62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | - $view->addHelper( 'config', $helper ); |
|
| 64 | - |
|
| 65 | - $client = \Aimeos\Client\Html\Email\Payment\Factory::createClient( $context, $templatePaths ); |
|
| 66 | - |
|
| 67 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | - $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | - $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 70 | - |
|
| 71 | - /** controller/jobs/order/email/payment/standard/limit-days |
|
| 72 | - * Only send payment e-mails of orders that were created in the past within the configured number of days |
|
| 73 | - * |
|
| 74 | - * The payment e-mails are normally send immediately after the payment |
|
| 75 | - * status has changed. This option prevents e-mails for old order from |
|
| 76 | - * being send in case anything went wrong or an update failed to avoid |
|
| 77 | - * confusion of customers. |
|
| 78 | - * |
|
| 79 | - * @param integer Number of days |
|
| 80 | - * @since 2014.03 |
|
| 81 | - * @category User |
|
| 82 | - * @category Developer |
|
| 83 | - * @see controller/jobs/order/email/delivery/standard/limit-days |
|
| 84 | - * @see controller/jobs/service/delivery/process/limit-days |
|
| 85 | - */ |
|
| 86 | - $limit = $config->get( 'controller/jobs/order/email/payment/standard/limit-days', 30 ); |
|
| 87 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 88 | - |
|
| 89 | - $default = array( |
|
| 90 | - \Aimeos\MShop\Order\Item\Base::PAY_REFUND, |
|
| 91 | - \Aimeos\MShop\Order\Item\Base::PAY_PENDING, |
|
| 92 | - \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED, |
|
| 93 | - \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED, |
|
| 94 | - ); |
|
| 95 | - |
|
| 96 | - /** controller/jobs/order/email/payment/standard/status |
|
| 97 | - * Only send order payment notification e-mails for these payment status values |
|
| 98 | - * |
|
| 99 | - * Notification e-mail about payment status changes can be sent for these |
|
| 100 | - * status values: |
|
| 101 | - * * 0: deleted |
|
| 102 | - * * 1: canceled |
|
| 103 | - * * 2: refused |
|
| 104 | - * * 3: refund |
|
| 105 | - * * 4: pending |
|
| 106 | - * * 5: authorized |
|
| 107 | - * * 6: received |
|
| 108 | - * |
|
| 109 | - * User-defined status values are possible but should be in the private |
|
| 110 | - * block of values between 30000 and 32767. |
|
| 111 | - * |
|
| 112 | - * @param integer Payment status constant |
|
| 113 | - * @since 2014.03 |
|
| 114 | - * @category User |
|
| 115 | - * @category Developer |
|
| 116 | - * @see controller/jobs/order/email/delivery/standard/status |
|
| 117 | - * @see controller/jobs/order/email/payment/standard/limit-days |
|
| 118 | - */ |
|
| 119 | - foreach( (array) $config->get( 'controller/jobs/order/email/payment/standard/status', $default ) as $status ) |
|
| 120 | - { |
|
| 121 | - $orderSearch = $orderManager->createSearch(); |
|
| 122 | - |
|
| 123 | - $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT, $status ); |
|
| 124 | - $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 125 | - |
|
| 126 | - $expr = array( |
|
| 127 | - $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 128 | - $orderSearch->compare( '==', 'order.statuspayment', $status ), |
|
| 129 | - $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 130 | - ); |
|
| 131 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 132 | - |
|
| 133 | - $start = 0; |
|
| 134 | - |
|
| 135 | - do |
|
| 136 | - { |
|
| 137 | - $items = $orderManager->searchItems( $orderSearch ); |
|
| 138 | - |
|
| 139 | - foreach( $items as $id => $item ) |
|
| 140 | - { |
|
| 141 | - try |
|
| 142 | - { |
|
| 143 | - $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 144 | - |
|
| 145 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 146 | - |
|
| 147 | - $view->extAddressItem = $addr; |
|
| 148 | - $view->extOrderBaseItem = $orderBaseItem; |
|
| 149 | - $view->extOrderItem = $item; |
|
| 150 | - |
|
| 151 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 152 | - $view->addHelper( 'translate', $helper ); |
|
| 153 | - |
|
| 154 | - $message = $mailer->createMessage(); |
|
| 155 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 156 | - $view->addHelper( 'mail', $helper ); |
|
| 157 | - |
|
| 158 | - $client->setView( $view ); |
|
| 159 | - $client->getHeader(); |
|
| 160 | - $client->getBody(); |
|
| 161 | - |
|
| 162 | - $mailer->send( $message ); |
|
| 163 | - |
|
| 164 | - $statusItem = $orderStatusManager->createItem(); |
|
| 165 | - $statusItem->setParentId( $id ); |
|
| 166 | - $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT ); |
|
| 167 | - $statusItem->setValue( $status ); |
|
| 168 | - |
|
| 169 | - $orderStatusManager->saveItem( $statusItem ); |
|
| 170 | - } |
|
| 171 | - catch( \Exception $e ) |
|
| 172 | - { |
|
| 173 | - $str = 'Error while trying to send payment e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
|
| 174 | - $msg = sprintf( $str, $item->getId(), $item->getPaymentStatus(), $e->getMessage() ); |
|
| 175 | - $context->getLogger()->log( $msg ); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $count = count( $items ); |
|
| 180 | - $start += $count; |
|
| 181 | - $orderSearch->setSlice( $start ); |
|
| 182 | - } |
|
| 183 | - while( $count >= $orderSearch->getSliceSize() ); |
|
| 184 | - } |
|
| 185 | - } |
|
| 25 | + /** |
|
| 26 | + * Returns the localized name of the job. |
|
| 27 | + * |
|
| 28 | + * @return string Name of the job |
|
| 29 | + */ |
|
| 30 | + public function getName() |
|
| 31 | + { |
|
| 32 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order payment related e-mails' ); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Returns the localized description of the job. |
|
| 38 | + * |
|
| 39 | + * @return string Description of the job |
|
| 40 | + */ |
|
| 41 | + public function getDescription() |
|
| 42 | + { |
|
| 43 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order confirmation or payment status update e-mails' ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Executes the job. |
|
| 49 | + * |
|
| 50 | + * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 51 | + */ |
|
| 52 | + public function run() |
|
| 53 | + { |
|
| 54 | + $aimeos = $this->getAimeos(); |
|
| 55 | + $context = $this->getContext(); |
|
| 56 | + $config = $context->getConfig(); |
|
| 57 | + $mailer = $context->getMail(); |
|
| 58 | + $view = $context->getView(); |
|
| 59 | + |
|
| 60 | + $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 61 | + |
|
| 62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | + $view->addHelper( 'config', $helper ); |
|
| 64 | + |
|
| 65 | + $client = \Aimeos\Client\Html\Email\Payment\Factory::createClient( $context, $templatePaths ); |
|
| 66 | + |
|
| 67 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | + $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | + $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 70 | + |
|
| 71 | + /** controller/jobs/order/email/payment/standard/limit-days |
|
| 72 | + * Only send payment e-mails of orders that were created in the past within the configured number of days |
|
| 73 | + * |
|
| 74 | + * The payment e-mails are normally send immediately after the payment |
|
| 75 | + * status has changed. This option prevents e-mails for old order from |
|
| 76 | + * being send in case anything went wrong or an update failed to avoid |
|
| 77 | + * confusion of customers. |
|
| 78 | + * |
|
| 79 | + * @param integer Number of days |
|
| 80 | + * @since 2014.03 |
|
| 81 | + * @category User |
|
| 82 | + * @category Developer |
|
| 83 | + * @see controller/jobs/order/email/delivery/standard/limit-days |
|
| 84 | + * @see controller/jobs/service/delivery/process/limit-days |
|
| 85 | + */ |
|
| 86 | + $limit = $config->get( 'controller/jobs/order/email/payment/standard/limit-days', 30 ); |
|
| 87 | + $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 88 | + |
|
| 89 | + $default = array( |
|
| 90 | + \Aimeos\MShop\Order\Item\Base::PAY_REFUND, |
|
| 91 | + \Aimeos\MShop\Order\Item\Base::PAY_PENDING, |
|
| 92 | + \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED, |
|
| 93 | + \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED, |
|
| 94 | + ); |
|
| 95 | + |
|
| 96 | + /** controller/jobs/order/email/payment/standard/status |
|
| 97 | + * Only send order payment notification e-mails for these payment status values |
|
| 98 | + * |
|
| 99 | + * Notification e-mail about payment status changes can be sent for these |
|
| 100 | + * status values: |
|
| 101 | + * * 0: deleted |
|
| 102 | + * * 1: canceled |
|
| 103 | + * * 2: refused |
|
| 104 | + * * 3: refund |
|
| 105 | + * * 4: pending |
|
| 106 | + * * 5: authorized |
|
| 107 | + * * 6: received |
|
| 108 | + * |
|
| 109 | + * User-defined status values are possible but should be in the private |
|
| 110 | + * block of values between 30000 and 32767. |
|
| 111 | + * |
|
| 112 | + * @param integer Payment status constant |
|
| 113 | + * @since 2014.03 |
|
| 114 | + * @category User |
|
| 115 | + * @category Developer |
|
| 116 | + * @see controller/jobs/order/email/delivery/standard/status |
|
| 117 | + * @see controller/jobs/order/email/payment/standard/limit-days |
|
| 118 | + */ |
|
| 119 | + foreach( (array) $config->get( 'controller/jobs/order/email/payment/standard/status', $default ) as $status ) |
|
| 120 | + { |
|
| 121 | + $orderSearch = $orderManager->createSearch(); |
|
| 122 | + |
|
| 123 | + $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT, $status ); |
|
| 124 | + $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 125 | + |
|
| 126 | + $expr = array( |
|
| 127 | + $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 128 | + $orderSearch->compare( '==', 'order.statuspayment', $status ), |
|
| 129 | + $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 130 | + ); |
|
| 131 | + $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 132 | + |
|
| 133 | + $start = 0; |
|
| 134 | + |
|
| 135 | + do |
|
| 136 | + { |
|
| 137 | + $items = $orderManager->searchItems( $orderSearch ); |
|
| 138 | + |
|
| 139 | + foreach( $items as $id => $item ) |
|
| 140 | + { |
|
| 141 | + try |
|
| 142 | + { |
|
| 143 | + $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 144 | + |
|
| 145 | + $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 146 | + |
|
| 147 | + $view->extAddressItem = $addr; |
|
| 148 | + $view->extOrderBaseItem = $orderBaseItem; |
|
| 149 | + $view->extOrderItem = $item; |
|
| 150 | + |
|
| 151 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 152 | + $view->addHelper( 'translate', $helper ); |
|
| 153 | + |
|
| 154 | + $message = $mailer->createMessage(); |
|
| 155 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 156 | + $view->addHelper( 'mail', $helper ); |
|
| 157 | + |
|
| 158 | + $client->setView( $view ); |
|
| 159 | + $client->getHeader(); |
|
| 160 | + $client->getBody(); |
|
| 161 | + |
|
| 162 | + $mailer->send( $message ); |
|
| 163 | + |
|
| 164 | + $statusItem = $orderStatusManager->createItem(); |
|
| 165 | + $statusItem->setParentId( $id ); |
|
| 166 | + $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT ); |
|
| 167 | + $statusItem->setValue( $status ); |
|
| 168 | + |
|
| 169 | + $orderStatusManager->saveItem( $statusItem ); |
|
| 170 | + } |
|
| 171 | + catch( \Exception $e ) |
|
| 172 | + { |
|
| 173 | + $str = 'Error while trying to send payment e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
|
| 174 | + $msg = sprintf( $str, $item->getId(), $item->getPaymentStatus(), $e->getMessage() ); |
|
| 175 | + $context->getLogger()->log( $msg ); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $count = count( $items ); |
|
| 180 | + $start += $count; |
|
| 181 | + $orderSearch->setSlice( $start ); |
|
| 182 | + } |
|
| 183 | + while( $count >= $orderSearch->getSliceSize() ); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | 186 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function getName() |
| 31 | 31 | { |
| 32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order payment related e-mails' ); |
|
| 32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Order payment related e-mails'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function getDescription() |
| 42 | 42 | { |
| 43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order confirmation or payment status update e-mails' ); |
|
| 43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends order confirmation or payment status update e-mails'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | $mailer = $context->getMail(); |
| 58 | 58 | $view = $context->getView(); |
| 59 | 59 | |
| 60 | - $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 60 | + $templatePaths = $aimeos->getCustomPaths('client/html/templates'); |
|
| 61 | 61 | |
| 62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | - $view->addHelper( 'config', $helper ); |
|
| 62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
| 63 | + $view->addHelper('config', $helper); |
|
| 64 | 64 | |
| 65 | - $client = \Aimeos\Client\Html\Email\Payment\Factory::createClient( $context, $templatePaths ); |
|
| 65 | + $client = \Aimeos\Client\Html\Email\Payment\Factory::createClient($context, $templatePaths); |
|
| 66 | 66 | |
| 67 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | - $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | - $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 67 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); |
|
| 68 | + $orderStatusManager = $orderManager->getSubManager('status'); |
|
| 69 | + $orderBaseManager = $orderManager->getSubManager('base'); |
|
| 70 | 70 | |
| 71 | 71 | /** controller/jobs/order/email/payment/standard/limit-days |
| 72 | 72 | * Only send payment e-mails of orders that were created in the past within the configured number of days |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | * @see controller/jobs/order/email/delivery/standard/limit-days |
| 84 | 84 | * @see controller/jobs/service/delivery/process/limit-days |
| 85 | 85 | */ |
| 86 | - $limit = $config->get( 'controller/jobs/order/email/payment/standard/limit-days', 30 ); |
|
| 87 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 86 | + $limit = $config->get('controller/jobs/order/email/payment/standard/limit-days', 30); |
|
| 87 | + $limitDate = date('Y-m-d H:i:s', time() - $limit * 86400); |
|
| 88 | 88 | |
| 89 | 89 | $default = array( |
| 90 | 90 | \Aimeos\MShop\Order\Item\Base::PAY_REFUND, |
@@ -116,71 +116,71 @@ discard block |
||
| 116 | 116 | * @see controller/jobs/order/email/delivery/standard/status |
| 117 | 117 | * @see controller/jobs/order/email/payment/standard/limit-days |
| 118 | 118 | */ |
| 119 | - foreach( (array) $config->get( 'controller/jobs/order/email/payment/standard/status', $default ) as $status ) |
|
| 119 | + foreach ((array) $config->get('controller/jobs/order/email/payment/standard/status', $default) as $status) |
|
| 120 | 120 | { |
| 121 | 121 | $orderSearch = $orderManager->createSearch(); |
| 122 | 122 | |
| 123 | - $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT, $status ); |
|
| 124 | - $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 123 | + $param = array(\Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT, $status); |
|
| 124 | + $orderFunc = $orderSearch->createFunction('order.containsStatus', $param); |
|
| 125 | 125 | |
| 126 | 126 | $expr = array( |
| 127 | - $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 128 | - $orderSearch->compare( '==', 'order.statuspayment', $status ), |
|
| 129 | - $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 127 | + $orderSearch->compare('>=', 'order.mtime', $limitDate), |
|
| 128 | + $orderSearch->compare('==', 'order.statuspayment', $status), |
|
| 129 | + $orderSearch->compare('==', $orderFunc, 0), |
|
| 130 | 130 | ); |
| 131 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 131 | + $orderSearch->setConditions($orderSearch->combine('&&', $expr)); |
|
| 132 | 132 | |
| 133 | 133 | $start = 0; |
| 134 | 134 | |
| 135 | 135 | do |
| 136 | 136 | { |
| 137 | - $items = $orderManager->searchItems( $orderSearch ); |
|
| 137 | + $items = $orderManager->searchItems($orderSearch); |
|
| 138 | 138 | |
| 139 | - foreach( $items as $id => $item ) |
|
| 139 | + foreach ($items as $id => $item) |
|
| 140 | 140 | { |
| 141 | 141 | try |
| 142 | 142 | { |
| 143 | - $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 143 | + $orderBaseItem = $orderBaseManager->load($item->getBaseId()); |
|
| 144 | 144 | |
| 145 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 145 | + $addr = $orderBaseItem->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 146 | 146 | |
| 147 | 147 | $view->extAddressItem = $addr; |
| 148 | 148 | $view->extOrderBaseItem = $orderBaseItem; |
| 149 | 149 | $view->extOrderItem = $item; |
| 150 | 150 | |
| 151 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 152 | - $view->addHelper( 'translate', $helper ); |
|
| 151 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($addr->getLanguageId())); |
|
| 152 | + $view->addHelper('translate', $helper); |
|
| 153 | 153 | |
| 154 | 154 | $message = $mailer->createMessage(); |
| 155 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 156 | - $view->addHelper( 'mail', $helper ); |
|
| 155 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); |
|
| 156 | + $view->addHelper('mail', $helper); |
|
| 157 | 157 | |
| 158 | - $client->setView( $view ); |
|
| 158 | + $client->setView($view); |
|
| 159 | 159 | $client->getHeader(); |
| 160 | 160 | $client->getBody(); |
| 161 | 161 | |
| 162 | - $mailer->send( $message ); |
|
| 162 | + $mailer->send($message); |
|
| 163 | 163 | |
| 164 | 164 | $statusItem = $orderStatusManager->createItem(); |
| 165 | - $statusItem->setParentId( $id ); |
|
| 166 | - $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT ); |
|
| 167 | - $statusItem->setValue( $status ); |
|
| 165 | + $statusItem->setParentId($id); |
|
| 166 | + $statusItem->setType(\Aimeos\MShop\Order\Item\Status\Base::EMAIL_PAYMENT); |
|
| 167 | + $statusItem->setValue($status); |
|
| 168 | 168 | |
| 169 | - $orderStatusManager->saveItem( $statusItem ); |
|
| 169 | + $orderStatusManager->saveItem($statusItem); |
|
| 170 | 170 | } |
| 171 | - catch( \Exception $e ) |
|
| 171 | + catch (\Exception $e) |
|
| 172 | 172 | { |
| 173 | 173 | $str = 'Error while trying to send payment e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
| 174 | - $msg = sprintf( $str, $item->getId(), $item->getPaymentStatus(), $e->getMessage() ); |
|
| 175 | - $context->getLogger()->log( $msg ); |
|
| 174 | + $msg = sprintf($str, $item->getId(), $item->getPaymentStatus(), $e->getMessage()); |
|
| 175 | + $context->getLogger()->log($msg); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $count = count( $items ); |
|
| 179 | + $count = count($items); |
|
| 180 | 180 | $start += $count; |
| 181 | - $orderSearch->setSlice( $start ); |
|
| 181 | + $orderSearch->setSlice($start); |
|
| 182 | 182 | } |
| 183 | - while( $count >= $orderSearch->getSliceSize() ); |
|
| 183 | + while ($count >= $orderSearch->getSliceSize()); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -167,8 +167,7 @@ |
||
| 167 | 167 | $statusItem->setValue( $status ); |
| 168 | 168 | |
| 169 | 169 | $orderStatusManager->saveItem( $statusItem ); |
| 170 | - } |
|
| 171 | - catch( \Exception $e ) |
|
| 170 | + } catch( \Exception $e ) |
|
| 172 | 171 | { |
| 173 | 172 | $str = 'Error while trying to send payment e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
| 174 | 173 | $msg = sprintf( $str, $item->getId(), $item->getPaymentStatus(), $e->getMessage() ); |
@@ -19,141 +19,141 @@ |
||
| 19 | 19 | * @subpackage Order |
| 20 | 20 | */ |
| 21 | 21 | class Factory |
| 22 | - extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Creates a new controller specified by the given name. |
|
| 27 | - * |
|
| 28 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | - * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | - * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | - * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | - */ |
|
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | - { |
|
| 35 | - /** controller/jobs/order/email/delivery/name |
|
| 36 | - * Class name of the used order email delivery scheduler controller implementation |
|
| 37 | - * |
|
| 38 | - * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | - * To use this implementation, you have to set the last part of the class |
|
| 40 | - * name as configuration value so the controller factory knows which class it |
|
| 41 | - * has to instantiate. |
|
| 42 | - * |
|
| 43 | - * For example, if the name of the default class is |
|
| 44 | - * |
|
| 45 | - * \Aimeos\Controller\Jobs\Order\Email\Delivery\Standard |
|
| 46 | - * |
|
| 47 | - * and you want to replace it with your own version named |
|
| 48 | - * |
|
| 49 | - * \Aimeos\Controller\Jobs\Order\Email\Delivery\Mydelivery |
|
| 50 | - * |
|
| 51 | - * then you have to set the this configuration option: |
|
| 52 | - * |
|
| 53 | - * controller/jobs/order/email/delivery/name = Mydelivery |
|
| 54 | - * |
|
| 55 | - * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | - * so take care that the configuration value is exactly named like the last |
|
| 57 | - * part of the class name. |
|
| 58 | - * |
|
| 59 | - * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | - * characters are possible! You should always start the last part of the class |
|
| 61 | - * name with an upper case character and continue only with lower case characters |
|
| 62 | - * or numbers. Avoid chamel case names like "MyDelivery"! |
|
| 63 | - * |
|
| 64 | - * @param string Last part of the class name |
|
| 65 | - * @since 2014.03 |
|
| 66 | - * @category Developer |
|
| 67 | - */ |
|
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/order/email/delivery/name', 'Standard' ); |
|
| 70 | - } |
|
| 25 | + /** |
|
| 26 | + * Creates a new controller specified by the given name. |
|
| 27 | + * |
|
| 28 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | + * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | + * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | + * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | + */ |
|
| 33 | + public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | + { |
|
| 35 | + /** controller/jobs/order/email/delivery/name |
|
| 36 | + * Class name of the used order email delivery scheduler controller implementation |
|
| 37 | + * |
|
| 38 | + * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | + * To use this implementation, you have to set the last part of the class |
|
| 40 | + * name as configuration value so the controller factory knows which class it |
|
| 41 | + * has to instantiate. |
|
| 42 | + * |
|
| 43 | + * For example, if the name of the default class is |
|
| 44 | + * |
|
| 45 | + * \Aimeos\Controller\Jobs\Order\Email\Delivery\Standard |
|
| 46 | + * |
|
| 47 | + * and you want to replace it with your own version named |
|
| 48 | + * |
|
| 49 | + * \Aimeos\Controller\Jobs\Order\Email\Delivery\Mydelivery |
|
| 50 | + * |
|
| 51 | + * then you have to set the this configuration option: |
|
| 52 | + * |
|
| 53 | + * controller/jobs/order/email/delivery/name = Mydelivery |
|
| 54 | + * |
|
| 55 | + * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | + * so take care that the configuration value is exactly named like the last |
|
| 57 | + * part of the class name. |
|
| 58 | + * |
|
| 59 | + * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | + * characters are possible! You should always start the last part of the class |
|
| 61 | + * name with an upper case character and continue only with lower case characters |
|
| 62 | + * or numbers. Avoid chamel case names like "MyDelivery"! |
|
| 63 | + * |
|
| 64 | + * @param string Last part of the class name |
|
| 65 | + * @since 2014.03 |
|
| 66 | + * @category Developer |
|
| 67 | + */ |
|
| 68 | + if( $name === null ) { |
|
| 69 | + $name = $context->getConfig()->get( 'controller/jobs/order/email/delivery/name', 'Standard' ); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 73 | - { |
|
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | - } |
|
| 72 | + if( ctype_alnum( $name ) === false ) |
|
| 73 | + { |
|
| 74 | + $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name; |
|
| 78 | + $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 82 | 82 | |
| 83 | - /** controller/jobs/order/email/delivery/decorators/excludes |
|
| 84 | - * Excludes decorators added by the "common" option from the order email delivery controllers |
|
| 85 | - * |
|
| 86 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | - * modify what is returned to the caller. |
|
| 90 | - * |
|
| 91 | - * This option allows you to remove a decorator added via |
|
| 92 | - * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | - * around the job controller. |
|
| 94 | - * |
|
| 95 | - * controller/jobs/order/email/delivery/decorators/excludes = array( 'decorator1' ) |
|
| 96 | - * |
|
| 97 | - * This would remove the decorator named "decorator1" from the list of |
|
| 98 | - * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | - * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | - * |
|
| 101 | - * @param array List of decorator names |
|
| 102 | - * @since 2015.09 |
|
| 103 | - * @category Developer |
|
| 104 | - * @see controller/jobs/common/decorators/default |
|
| 105 | - * @see controller/jobs/order/email/delivery/decorators/global |
|
| 106 | - * @see controller/jobs/order/email/delivery/decorators/local |
|
| 107 | - */ |
|
| 83 | + /** controller/jobs/order/email/delivery/decorators/excludes |
|
| 84 | + * Excludes decorators added by the "common" option from the order email delivery controllers |
|
| 85 | + * |
|
| 86 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | + * modify what is returned to the caller. |
|
| 90 | + * |
|
| 91 | + * This option allows you to remove a decorator added via |
|
| 92 | + * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | + * around the job controller. |
|
| 94 | + * |
|
| 95 | + * controller/jobs/order/email/delivery/decorators/excludes = array( 'decorator1' ) |
|
| 96 | + * |
|
| 97 | + * This would remove the decorator named "decorator1" from the list of |
|
| 98 | + * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | + * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | + * |
|
| 101 | + * @param array List of decorator names |
|
| 102 | + * @since 2015.09 |
|
| 103 | + * @category Developer |
|
| 104 | + * @see controller/jobs/common/decorators/default |
|
| 105 | + * @see controller/jobs/order/email/delivery/decorators/global |
|
| 106 | + * @see controller/jobs/order/email/delivery/decorators/local |
|
| 107 | + */ |
|
| 108 | 108 | |
| 109 | - /** controller/jobs/order/email/delivery/decorators/global |
|
| 110 | - * Adds a list of globally available decorators only to the order email delivery controllers |
|
| 111 | - * |
|
| 112 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | - * modify what is returned to the caller. |
|
| 116 | - * |
|
| 117 | - * This option allows you to wrap global decorators |
|
| 118 | - * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | - * |
|
| 120 | - * controller/jobs/order/email/delivery/decorators/global = array( 'decorator1' ) |
|
| 121 | - * |
|
| 122 | - * This would add the decorator named "decorator1" defined by |
|
| 123 | - * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | - * |
|
| 125 | - * @param array List of decorator names |
|
| 126 | - * @since 2015.09 |
|
| 127 | - * @category Developer |
|
| 128 | - * @see controller/jobs/common/decorators/default |
|
| 129 | - * @see controller/jobs/order/email/delivery/decorators/excludes |
|
| 130 | - * @see controller/jobs/order/email/delivery/decorators/local |
|
| 131 | - */ |
|
| 109 | + /** controller/jobs/order/email/delivery/decorators/global |
|
| 110 | + * Adds a list of globally available decorators only to the order email delivery controllers |
|
| 111 | + * |
|
| 112 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | + * modify what is returned to the caller. |
|
| 116 | + * |
|
| 117 | + * This option allows you to wrap global decorators |
|
| 118 | + * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | + * |
|
| 120 | + * controller/jobs/order/email/delivery/decorators/global = array( 'decorator1' ) |
|
| 121 | + * |
|
| 122 | + * This would add the decorator named "decorator1" defined by |
|
| 123 | + * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | + * |
|
| 125 | + * @param array List of decorator names |
|
| 126 | + * @since 2015.09 |
|
| 127 | + * @category Developer |
|
| 128 | + * @see controller/jobs/common/decorators/default |
|
| 129 | + * @see controller/jobs/order/email/delivery/decorators/excludes |
|
| 130 | + * @see controller/jobs/order/email/delivery/decorators/local |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | - /** controller/jobs/order/email/delivery/decorators/local |
|
| 134 | - * Adds a list of local decorators only to the order email delivery controllers |
|
| 135 | - * |
|
| 136 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | - * modify what is returned to the caller. |
|
| 140 | - * |
|
| 141 | - * This option allows you to wrap local decorators |
|
| 142 | - * ("\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\*") around this job controller. |
|
| 143 | - * |
|
| 144 | - * controller/jobs/order/email/delivery/decorators/local = array( 'decorator2' ) |
|
| 145 | - * |
|
| 146 | - * This would add the decorator named "decorator2" defined by |
|
| 147 | - * "\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\Decorator2" only to this job |
|
| 148 | - * controller. |
|
| 149 | - * |
|
| 150 | - * @param array List of decorator names |
|
| 151 | - * @since 2015.09 |
|
| 152 | - * @category Developer |
|
| 153 | - * @see controller/jobs/common/decorators/default |
|
| 154 | - * @see controller/jobs/order/email/delivery/decorators/excludes |
|
| 155 | - * @see controller/jobs/order/email/delivery/decorators/global |
|
| 156 | - */ |
|
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/delivery' ); |
|
| 158 | - } |
|
| 133 | + /** controller/jobs/order/email/delivery/decorators/local |
|
| 134 | + * Adds a list of local decorators only to the order email delivery controllers |
|
| 135 | + * |
|
| 136 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | + * modify what is returned to the caller. |
|
| 140 | + * |
|
| 141 | + * This option allows you to wrap local decorators |
|
| 142 | + * ("\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\*") around this job controller. |
|
| 143 | + * |
|
| 144 | + * controller/jobs/order/email/delivery/decorators/local = array( 'decorator2' ) |
|
| 145 | + * |
|
| 146 | + * This would add the decorator named "decorator2" defined by |
|
| 147 | + * "\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\Decorator2" only to this job |
|
| 148 | + * controller. |
|
| 149 | + * |
|
| 150 | + * @param array List of decorator names |
|
| 151 | + * @since 2015.09 |
|
| 152 | + * @category Developer |
|
| 153 | + * @see controller/jobs/common/decorators/default |
|
| 154 | + * @see controller/jobs/order/email/delivery/decorators/excludes |
|
| 155 | + * @see controller/jobs/order/email/delivery/decorators/global |
|
| 156 | + */ |
|
| 157 | + return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/delivery' ); |
|
| 158 | + } |
|
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string|null $name Name of the controller or "Standard" if null |
| 31 | 31 | * @return \Aimeos\Controller\Jobs\Iface New controller object |
| 32 | 32 | */ |
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 33 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) |
|
| 34 | 34 | { |
| 35 | 35 | /** controller/jobs/order/email/delivery/name |
| 36 | 36 | * Class name of the used order email delivery scheduler controller implementation |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | * @since 2014.03 |
| 66 | 66 | * @category Developer |
| 67 | 67 | */ |
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/order/email/delivery/name', 'Standard' ); |
|
| 68 | + if ($name === null) { |
|
| 69 | + $name = $context->getConfig()->get('controller/jobs/order/email/delivery/name', 'Standard'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 72 | + if (ctype_alnum($name) === false) |
|
| 73 | 73 | { |
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 74 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\'.$name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\'.$name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); |
|
| 82 | 82 | |
| 83 | 83 | /** controller/jobs/order/email/delivery/decorators/excludes |
| 84 | 84 | * Excludes decorators added by the "common" option from the order email delivery controllers |
@@ -154,6 +154,6 @@ discard block |
||
| 154 | 154 | * @see controller/jobs/order/email/delivery/decorators/excludes |
| 155 | 155 | * @see controller/jobs/order/email/delivery/decorators/global |
| 156 | 156 | */ |
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/delivery' ); |
|
| 157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'order/email/delivery'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -19,174 +19,174 @@ |
||
| 19 | 19 | * @subpackage Order |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Controller\Jobs\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Returns the localized name of the job. |
|
| 27 | - * |
|
| 28 | - * @return string Name of the job |
|
| 29 | - */ |
|
| 30 | - public function getName() |
|
| 31 | - { |
|
| 32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order delivery related e-mails' ); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Returns the localized description of the job. |
|
| 38 | - * |
|
| 39 | - * @return string Description of the job |
|
| 40 | - */ |
|
| 41 | - public function getDescription() |
|
| 42 | - { |
|
| 43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order delivery status update e-mails' ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Executes the job. |
|
| 49 | - * |
|
| 50 | - * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 51 | - */ |
|
| 52 | - public function run() |
|
| 53 | - { |
|
| 54 | - $aimeos = $this->getAimeos(); |
|
| 55 | - $context = $this->getContext(); |
|
| 56 | - $config = $context->getConfig(); |
|
| 57 | - $mailer = $context->getMail(); |
|
| 58 | - $view = $context->getView(); |
|
| 59 | - |
|
| 60 | - $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 61 | - |
|
| 62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | - $view->addHelper( 'config', $helper ); |
|
| 64 | - |
|
| 65 | - $client = \Aimeos\Client\Html\Email\Delivery\Factory::createClient( $context, $templatePaths ); |
|
| 66 | - |
|
| 67 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | - $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | - $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 70 | - |
|
| 71 | - /** controller/jobs/order/email/delivery/standard/limit-days |
|
| 72 | - * Only send delivery e-mails of orders that were created in the past within the configured number of days |
|
| 73 | - * |
|
| 74 | - * The delivery e-mails are normally send immediately after the delivery |
|
| 75 | - * status has changed. This option prevents e-mails for old order from |
|
| 76 | - * being send in case anything went wrong or an update failed to avoid |
|
| 77 | - * confusion of customers. |
|
| 78 | - * |
|
| 79 | - * @param integer Number of days |
|
| 80 | - * @since 2014.03 |
|
| 81 | - * @category User |
|
| 82 | - * @category Developer |
|
| 83 | - * @see controller/jobs/order/email/delivery/standard/status |
|
| 84 | - * @see controller/jobs/order/email/payment/standard/limit-days |
|
| 85 | - * @see controller/jobs/service/delivery/process/limit-days |
|
| 86 | - */ |
|
| 87 | - $limit = $config->get( 'controller/jobs/order/email/delivery/standard/limit-days', 90 ); |
|
| 88 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 89 | - |
|
| 90 | - $default = array( |
|
| 91 | - \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, |
|
| 92 | - \Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, |
|
| 93 | - \Aimeos\MShop\Order\Item\Base::STAT_REFUSED, |
|
| 94 | - \Aimeos\MShop\Order\Item\Base::STAT_RETURNED, |
|
| 95 | - ); |
|
| 96 | - |
|
| 97 | - /** controller/jobs/order/email/delivery/standard/status |
|
| 98 | - * Only send order delivery notification e-mails for these delivery status values |
|
| 99 | - * |
|
| 100 | - * Notification e-mail about delivery status changes can be sent for these |
|
| 101 | - * status values: |
|
| 102 | - * * 0: deleted |
|
| 103 | - * * 1: pending |
|
| 104 | - * * 2: progress |
|
| 105 | - * * 3: dispatched |
|
| 106 | - * * 4: delivered |
|
| 107 | - * * 5: lost |
|
| 108 | - * * 6: refused |
|
| 109 | - * * 7: returned |
|
| 110 | - * |
|
| 111 | - * User-defined status values are possible but should be in the private |
|
| 112 | - * block of values between 30000 and 32767. |
|
| 113 | - * |
|
| 114 | - * @param integer Delivery status constant |
|
| 115 | - * @since 2014.03 |
|
| 116 | - * @category User |
|
| 117 | - * @category Developer |
|
| 118 | - * @see controller/jobs/order/email/payment/standard/status |
|
| 119 | - * @see controller/jobs/order/email/delivery/standard/limit-days |
|
| 120 | - */ |
|
| 121 | - foreach( (array) $config->get( 'controller/jobs/order/email/delivery/standard/status', $default ) as $status ) |
|
| 122 | - { |
|
| 123 | - $orderSearch = $orderManager->createSearch(); |
|
| 124 | - |
|
| 125 | - $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY, $status ); |
|
| 126 | - $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 127 | - |
|
| 128 | - $expr = array( |
|
| 129 | - $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 130 | - $orderSearch->compare( '==', 'order.statusdelivery', $status ), |
|
| 131 | - $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 132 | - ); |
|
| 133 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 134 | - |
|
| 135 | - $start = 0; |
|
| 136 | - |
|
| 137 | - do |
|
| 138 | - { |
|
| 139 | - $items = $orderManager->searchItems( $orderSearch ); |
|
| 140 | - |
|
| 141 | - foreach( $items as $id => $item ) |
|
| 142 | - { |
|
| 143 | - try |
|
| 144 | - { |
|
| 145 | - $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 146 | - |
|
| 147 | - try { |
|
| 148 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 149 | - } catch( \Exception $e ) { |
|
| 150 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - $view->extAddressItem = $addr; |
|
| 154 | - $view->extOrderBaseItem = $orderBaseItem; |
|
| 155 | - $view->extOrderItem = $item; |
|
| 156 | - |
|
| 157 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 158 | - $view->addHelper( 'translate', $helper ); |
|
| 159 | - |
|
| 160 | - $message = $mailer->createMessage(); |
|
| 161 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 162 | - $view->addHelper( 'mail', $helper ); |
|
| 163 | - |
|
| 164 | - $client->setView( $view ); |
|
| 165 | - $client->getHeader(); |
|
| 166 | - $client->getBody(); |
|
| 167 | - |
|
| 168 | - $mailer->send( $message ); |
|
| 169 | - |
|
| 170 | - $statusItem = $orderStatusManager->createItem(); |
|
| 171 | - $statusItem->setParentId( $id ); |
|
| 172 | - $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY ); |
|
| 173 | - $statusItem->setValue( $status ); |
|
| 174 | - |
|
| 175 | - $orderStatusManager->saveItem( $statusItem ); |
|
| 176 | - } |
|
| 177 | - catch( \Exception $e ) |
|
| 178 | - { |
|
| 179 | - $str = 'Error while trying to send delivery e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
|
| 180 | - $msg = sprintf( $str, $item->getId(), $item->getDeliveryStatus(), $e->getMessage() ); |
|
| 181 | - $context->getLogger()->log( $msg ); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $count = count( $items ); |
|
| 186 | - $start += $count; |
|
| 187 | - $orderSearch->setSlice( $start ); |
|
| 188 | - } |
|
| 189 | - while( $count >= $orderSearch->getSliceSize() ); |
|
| 190 | - } |
|
| 191 | - } |
|
| 25 | + /** |
|
| 26 | + * Returns the localized name of the job. |
|
| 27 | + * |
|
| 28 | + * @return string Name of the job |
|
| 29 | + */ |
|
| 30 | + public function getName() |
|
| 31 | + { |
|
| 32 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order delivery related e-mails' ); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Returns the localized description of the job. |
|
| 38 | + * |
|
| 39 | + * @return string Description of the job |
|
| 40 | + */ |
|
| 41 | + public function getDescription() |
|
| 42 | + { |
|
| 43 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order delivery status update e-mails' ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Executes the job. |
|
| 49 | + * |
|
| 50 | + * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 51 | + */ |
|
| 52 | + public function run() |
|
| 53 | + { |
|
| 54 | + $aimeos = $this->getAimeos(); |
|
| 55 | + $context = $this->getContext(); |
|
| 56 | + $config = $context->getConfig(); |
|
| 57 | + $mailer = $context->getMail(); |
|
| 58 | + $view = $context->getView(); |
|
| 59 | + |
|
| 60 | + $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 61 | + |
|
| 62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | + $view->addHelper( 'config', $helper ); |
|
| 64 | + |
|
| 65 | + $client = \Aimeos\Client\Html\Email\Delivery\Factory::createClient( $context, $templatePaths ); |
|
| 66 | + |
|
| 67 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | + $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | + $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 70 | + |
|
| 71 | + /** controller/jobs/order/email/delivery/standard/limit-days |
|
| 72 | + * Only send delivery e-mails of orders that were created in the past within the configured number of days |
|
| 73 | + * |
|
| 74 | + * The delivery e-mails are normally send immediately after the delivery |
|
| 75 | + * status has changed. This option prevents e-mails for old order from |
|
| 76 | + * being send in case anything went wrong or an update failed to avoid |
|
| 77 | + * confusion of customers. |
|
| 78 | + * |
|
| 79 | + * @param integer Number of days |
|
| 80 | + * @since 2014.03 |
|
| 81 | + * @category User |
|
| 82 | + * @category Developer |
|
| 83 | + * @see controller/jobs/order/email/delivery/standard/status |
|
| 84 | + * @see controller/jobs/order/email/payment/standard/limit-days |
|
| 85 | + * @see controller/jobs/service/delivery/process/limit-days |
|
| 86 | + */ |
|
| 87 | + $limit = $config->get( 'controller/jobs/order/email/delivery/standard/limit-days', 90 ); |
|
| 88 | + $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 89 | + |
|
| 90 | + $default = array( |
|
| 91 | + \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, |
|
| 92 | + \Aimeos\MShop\Order\Item\Base::STAT_DISPATCHED, |
|
| 93 | + \Aimeos\MShop\Order\Item\Base::STAT_REFUSED, |
|
| 94 | + \Aimeos\MShop\Order\Item\Base::STAT_RETURNED, |
|
| 95 | + ); |
|
| 96 | + |
|
| 97 | + /** controller/jobs/order/email/delivery/standard/status |
|
| 98 | + * Only send order delivery notification e-mails for these delivery status values |
|
| 99 | + * |
|
| 100 | + * Notification e-mail about delivery status changes can be sent for these |
|
| 101 | + * status values: |
|
| 102 | + * * 0: deleted |
|
| 103 | + * * 1: pending |
|
| 104 | + * * 2: progress |
|
| 105 | + * * 3: dispatched |
|
| 106 | + * * 4: delivered |
|
| 107 | + * * 5: lost |
|
| 108 | + * * 6: refused |
|
| 109 | + * * 7: returned |
|
| 110 | + * |
|
| 111 | + * User-defined status values are possible but should be in the private |
|
| 112 | + * block of values between 30000 and 32767. |
|
| 113 | + * |
|
| 114 | + * @param integer Delivery status constant |
|
| 115 | + * @since 2014.03 |
|
| 116 | + * @category User |
|
| 117 | + * @category Developer |
|
| 118 | + * @see controller/jobs/order/email/payment/standard/status |
|
| 119 | + * @see controller/jobs/order/email/delivery/standard/limit-days |
|
| 120 | + */ |
|
| 121 | + foreach( (array) $config->get( 'controller/jobs/order/email/delivery/standard/status', $default ) as $status ) |
|
| 122 | + { |
|
| 123 | + $orderSearch = $orderManager->createSearch(); |
|
| 124 | + |
|
| 125 | + $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY, $status ); |
|
| 126 | + $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 127 | + |
|
| 128 | + $expr = array( |
|
| 129 | + $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 130 | + $orderSearch->compare( '==', 'order.statusdelivery', $status ), |
|
| 131 | + $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 132 | + ); |
|
| 133 | + $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 134 | + |
|
| 135 | + $start = 0; |
|
| 136 | + |
|
| 137 | + do |
|
| 138 | + { |
|
| 139 | + $items = $orderManager->searchItems( $orderSearch ); |
|
| 140 | + |
|
| 141 | + foreach( $items as $id => $item ) |
|
| 142 | + { |
|
| 143 | + try |
|
| 144 | + { |
|
| 145 | + $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 146 | + |
|
| 147 | + try { |
|
| 148 | + $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 149 | + } catch( \Exception $e ) { |
|
| 150 | + $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + $view->extAddressItem = $addr; |
|
| 154 | + $view->extOrderBaseItem = $orderBaseItem; |
|
| 155 | + $view->extOrderItem = $item; |
|
| 156 | + |
|
| 157 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 158 | + $view->addHelper( 'translate', $helper ); |
|
| 159 | + |
|
| 160 | + $message = $mailer->createMessage(); |
|
| 161 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 162 | + $view->addHelper( 'mail', $helper ); |
|
| 163 | + |
|
| 164 | + $client->setView( $view ); |
|
| 165 | + $client->getHeader(); |
|
| 166 | + $client->getBody(); |
|
| 167 | + |
|
| 168 | + $mailer->send( $message ); |
|
| 169 | + |
|
| 170 | + $statusItem = $orderStatusManager->createItem(); |
|
| 171 | + $statusItem->setParentId( $id ); |
|
| 172 | + $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY ); |
|
| 173 | + $statusItem->setValue( $status ); |
|
| 174 | + |
|
| 175 | + $orderStatusManager->saveItem( $statusItem ); |
|
| 176 | + } |
|
| 177 | + catch( \Exception $e ) |
|
| 178 | + { |
|
| 179 | + $str = 'Error while trying to send delivery e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
|
| 180 | + $msg = sprintf( $str, $item->getId(), $item->getDeliveryStatus(), $e->getMessage() ); |
|
| 181 | + $context->getLogger()->log( $msg ); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $count = count( $items ); |
|
| 186 | + $start += $count; |
|
| 187 | + $orderSearch->setSlice( $start ); |
|
| 188 | + } |
|
| 189 | + while( $count >= $orderSearch->getSliceSize() ); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function getName() |
| 31 | 31 | { |
| 32 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order delivery related e-mails' ); |
|
| 32 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Order delivery related e-mails'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function getDescription() |
| 42 | 42 | { |
| 43 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends order delivery status update e-mails' ); |
|
| 43 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends order delivery status update e-mails'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | $mailer = $context->getMail(); |
| 58 | 58 | $view = $context->getView(); |
| 59 | 59 | |
| 60 | - $templatePaths = $aimeos->getCustomPaths( 'client/html/templates' ); |
|
| 60 | + $templatePaths = $aimeos->getCustomPaths('client/html/templates'); |
|
| 61 | 61 | |
| 62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | - $view->addHelper( 'config', $helper ); |
|
| 62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
| 63 | + $view->addHelper('config', $helper); |
|
| 64 | 64 | |
| 65 | - $client = \Aimeos\Client\Html\Email\Delivery\Factory::createClient( $context, $templatePaths ); |
|
| 65 | + $client = \Aimeos\Client\Html\Email\Delivery\Factory::createClient($context, $templatePaths); |
|
| 66 | 66 | |
| 67 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context ); |
|
| 68 | - $orderStatusManager = $orderManager->getSubManager( 'status' ); |
|
| 69 | - $orderBaseManager = $orderManager->getSubManager( 'base' ); |
|
| 67 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context); |
|
| 68 | + $orderStatusManager = $orderManager->getSubManager('status'); |
|
| 69 | + $orderBaseManager = $orderManager->getSubManager('base'); |
|
| 70 | 70 | |
| 71 | 71 | /** controller/jobs/order/email/delivery/standard/limit-days |
| 72 | 72 | * Only send delivery e-mails of orders that were created in the past within the configured number of days |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * @see controller/jobs/order/email/payment/standard/limit-days |
| 85 | 85 | * @see controller/jobs/service/delivery/process/limit-days |
| 86 | 86 | */ |
| 87 | - $limit = $config->get( 'controller/jobs/order/email/delivery/standard/limit-days', 90 ); |
|
| 88 | - $limitDate = date( 'Y-m-d H:i:s', time() - $limit * 86400 ); |
|
| 87 | + $limit = $config->get('controller/jobs/order/email/delivery/standard/limit-days', 90); |
|
| 88 | + $limitDate = date('Y-m-d H:i:s', time() - $limit * 86400); |
|
| 89 | 89 | |
| 90 | 90 | $default = array( |
| 91 | 91 | \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, |
@@ -118,75 +118,75 @@ discard block |
||
| 118 | 118 | * @see controller/jobs/order/email/payment/standard/status |
| 119 | 119 | * @see controller/jobs/order/email/delivery/standard/limit-days |
| 120 | 120 | */ |
| 121 | - foreach( (array) $config->get( 'controller/jobs/order/email/delivery/standard/status', $default ) as $status ) |
|
| 121 | + foreach ((array) $config->get('controller/jobs/order/email/delivery/standard/status', $default) as $status) |
|
| 122 | 122 | { |
| 123 | 123 | $orderSearch = $orderManager->createSearch(); |
| 124 | 124 | |
| 125 | - $param = array( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY, $status ); |
|
| 126 | - $orderFunc = $orderSearch->createFunction( 'order.containsStatus', $param ); |
|
| 125 | + $param = array(\Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY, $status); |
|
| 126 | + $orderFunc = $orderSearch->createFunction('order.containsStatus', $param); |
|
| 127 | 127 | |
| 128 | 128 | $expr = array( |
| 129 | - $orderSearch->compare( '>=', 'order.mtime', $limitDate ), |
|
| 130 | - $orderSearch->compare( '==', 'order.statusdelivery', $status ), |
|
| 131 | - $orderSearch->compare( '==', $orderFunc, 0 ), |
|
| 129 | + $orderSearch->compare('>=', 'order.mtime', $limitDate), |
|
| 130 | + $orderSearch->compare('==', 'order.statusdelivery', $status), |
|
| 131 | + $orderSearch->compare('==', $orderFunc, 0), |
|
| 132 | 132 | ); |
| 133 | - $orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) ); |
|
| 133 | + $orderSearch->setConditions($orderSearch->combine('&&', $expr)); |
|
| 134 | 134 | |
| 135 | 135 | $start = 0; |
| 136 | 136 | |
| 137 | 137 | do |
| 138 | 138 | { |
| 139 | - $items = $orderManager->searchItems( $orderSearch ); |
|
| 139 | + $items = $orderManager->searchItems($orderSearch); |
|
| 140 | 140 | |
| 141 | - foreach( $items as $id => $item ) |
|
| 141 | + foreach ($items as $id => $item) |
|
| 142 | 142 | { |
| 143 | 143 | try |
| 144 | 144 | { |
| 145 | - $orderBaseItem = $orderBaseManager->load( $item->getBaseId() ); |
|
| 145 | + $orderBaseItem = $orderBaseManager->load($item->getBaseId()); |
|
| 146 | 146 | |
| 147 | 147 | try { |
| 148 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
| 149 | - } catch( \Exception $e ) { |
|
| 150 | - $addr = $orderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
| 148 | + $addr = $orderBaseItem->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
| 149 | + } catch (\Exception $e) { |
|
| 150 | + $addr = $orderBaseItem->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $view->extAddressItem = $addr; |
| 154 | 154 | $view->extOrderBaseItem = $orderBaseItem; |
| 155 | 155 | $view->extOrderItem = $item; |
| 156 | 156 | |
| 157 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $addr->getLanguageId() ) ); |
|
| 158 | - $view->addHelper( 'translate', $helper ); |
|
| 157 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($addr->getLanguageId())); |
|
| 158 | + $view->addHelper('translate', $helper); |
|
| 159 | 159 | |
| 160 | 160 | $message = $mailer->createMessage(); |
| 161 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 162 | - $view->addHelper( 'mail', $helper ); |
|
| 161 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); |
|
| 162 | + $view->addHelper('mail', $helper); |
|
| 163 | 163 | |
| 164 | - $client->setView( $view ); |
|
| 164 | + $client->setView($view); |
|
| 165 | 165 | $client->getHeader(); |
| 166 | 166 | $client->getBody(); |
| 167 | 167 | |
| 168 | - $mailer->send( $message ); |
|
| 168 | + $mailer->send($message); |
|
| 169 | 169 | |
| 170 | 170 | $statusItem = $orderStatusManager->createItem(); |
| 171 | - $statusItem->setParentId( $id ); |
|
| 172 | - $statusItem->setType( \Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY ); |
|
| 173 | - $statusItem->setValue( $status ); |
|
| 171 | + $statusItem->setParentId($id); |
|
| 172 | + $statusItem->setType(\Aimeos\MShop\Order\Item\Status\Base::EMAIL_DELIVERY); |
|
| 173 | + $statusItem->setValue($status); |
|
| 174 | 174 | |
| 175 | - $orderStatusManager->saveItem( $statusItem ); |
|
| 175 | + $orderStatusManager->saveItem($statusItem); |
|
| 176 | 176 | } |
| 177 | - catch( \Exception $e ) |
|
| 177 | + catch (\Exception $e) |
|
| 178 | 178 | { |
| 179 | 179 | $str = 'Error while trying to send delivery e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
| 180 | - $msg = sprintf( $str, $item->getId(), $item->getDeliveryStatus(), $e->getMessage() ); |
|
| 181 | - $context->getLogger()->log( $msg ); |
|
| 180 | + $msg = sprintf($str, $item->getId(), $item->getDeliveryStatus(), $e->getMessage()); |
|
| 181 | + $context->getLogger()->log($msg); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $count = count( $items ); |
|
| 185 | + $count = count($items); |
|
| 186 | 186 | $start += $count; |
| 187 | - $orderSearch->setSlice( $start ); |
|
| 187 | + $orderSearch->setSlice($start); |
|
| 188 | 188 | } |
| 189 | - while( $count >= $orderSearch->getSliceSize() ); |
|
| 189 | + while ($count >= $orderSearch->getSliceSize()); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -173,8 +173,7 @@ |
||
| 173 | 173 | $statusItem->setValue( $status ); |
| 174 | 174 | |
| 175 | 175 | $orderStatusManager->saveItem( $statusItem ); |
| 176 | - } |
|
| 177 | - catch( \Exception $e ) |
|
| 176 | + } catch( \Exception $e ) |
|
| 178 | 177 | { |
| 179 | 178 | $str = 'Error while trying to send delivery e-mail for order ID "%1$s" and status "%2$s": %3$s'; |
| 180 | 179 | $msg = sprintf( $str, $item->getId(), $item->getDeliveryStatus(), $e->getMessage() ); |
@@ -18,141 +18,141 @@ |
||
| 18 | 18 | * @subpackage Jobs |
| 19 | 19 | */ |
| 20 | 20 | class Factory |
| 21 | - extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 22 | - implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 21 | + extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 22 | + implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * Creates a new controller specified by the given name. |
|
| 26 | - * |
|
| 27 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 28 | - * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 29 | - * @param string|null $name Name of the controller or "Standard" if null |
|
| 30 | - * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 31 | - */ |
|
| 32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 33 | - { |
|
| 34 | - /** controller/jobs/customer/email/account/name |
|
| 35 | - * Class name of the used product notification e-mail scheduler controller implementation |
|
| 36 | - * |
|
| 37 | - * Each default job controller can be replace by an alternative imlementation. |
|
| 38 | - * To use this implementation, you have to set the last part of the class |
|
| 39 | - * name as configuration value so the controller factory knows which class it |
|
| 40 | - * has to instantiate. |
|
| 41 | - * |
|
| 42 | - * For example, if the name of the default class is |
|
| 43 | - * |
|
| 44 | - * \Aimeos\Controller\Jobs\Customer\Email\Account\Standard |
|
| 45 | - * |
|
| 46 | - * and you want to replace it with your own version named |
|
| 47 | - * |
|
| 48 | - * \Aimeos\Controller\Jobs\Customer\Email\Account\Myaccount |
|
| 49 | - * |
|
| 50 | - * then you have to set the this configuration option: |
|
| 51 | - * |
|
| 52 | - * controller/jobs/customer/email/account/name = Myaccount |
|
| 53 | - * |
|
| 54 | - * The value is the last part of your own class name and it's case sensitive, |
|
| 55 | - * so take care that the configuration value is exactly named like the last |
|
| 56 | - * part of the class name. |
|
| 57 | - * |
|
| 58 | - * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 59 | - * characters are possible! You should always start the last part of the class |
|
| 60 | - * name with an upper case character and continue only with lower case characters |
|
| 61 | - * or numbers. Avoid chamel case names like "MyAccount"! |
|
| 62 | - * |
|
| 63 | - * @param string Last part of the class name |
|
| 64 | - * @since 2016.04 |
|
| 65 | - * @category Developer |
|
| 66 | - */ |
|
| 67 | - if( $name === null ) { |
|
| 68 | - $name = $context->getConfig()->get( 'controller/jobs/customer/email/account/name', 'Standard' ); |
|
| 69 | - } |
|
| 24 | + /** |
|
| 25 | + * Creates a new controller specified by the given name. |
|
| 26 | + * |
|
| 27 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 28 | + * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 29 | + * @param string|null $name Name of the controller or "Standard" if null |
|
| 30 | + * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 31 | + */ |
|
| 32 | + public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 33 | + { |
|
| 34 | + /** controller/jobs/customer/email/account/name |
|
| 35 | + * Class name of the used product notification e-mail scheduler controller implementation |
|
| 36 | + * |
|
| 37 | + * Each default job controller can be replace by an alternative imlementation. |
|
| 38 | + * To use this implementation, you have to set the last part of the class |
|
| 39 | + * name as configuration value so the controller factory knows which class it |
|
| 40 | + * has to instantiate. |
|
| 41 | + * |
|
| 42 | + * For example, if the name of the default class is |
|
| 43 | + * |
|
| 44 | + * \Aimeos\Controller\Jobs\Customer\Email\Account\Standard |
|
| 45 | + * |
|
| 46 | + * and you want to replace it with your own version named |
|
| 47 | + * |
|
| 48 | + * \Aimeos\Controller\Jobs\Customer\Email\Account\Myaccount |
|
| 49 | + * |
|
| 50 | + * then you have to set the this configuration option: |
|
| 51 | + * |
|
| 52 | + * controller/jobs/customer/email/account/name = Myaccount |
|
| 53 | + * |
|
| 54 | + * The value is the last part of your own class name and it's case sensitive, |
|
| 55 | + * so take care that the configuration value is exactly named like the last |
|
| 56 | + * part of the class name. |
|
| 57 | + * |
|
| 58 | + * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 59 | + * characters are possible! You should always start the last part of the class |
|
| 60 | + * name with an upper case character and continue only with lower case characters |
|
| 61 | + * or numbers. Avoid chamel case names like "MyAccount"! |
|
| 62 | + * |
|
| 63 | + * @param string Last part of the class name |
|
| 64 | + * @since 2016.04 |
|
| 65 | + * @category Developer |
|
| 66 | + */ |
|
| 67 | + if( $name === null ) { |
|
| 68 | + $name = $context->getConfig()->get( 'controller/jobs/customer/email/account/name', 'Standard' ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - if( ctype_alnum( $name ) === false ) |
|
| 72 | - { |
|
| 73 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name : '<not a string>'; |
|
| 74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 75 | - } |
|
| 71 | + if( ctype_alnum( $name ) === false ) |
|
| 72 | + { |
|
| 73 | + $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name : '<not a string>'; |
|
| 74 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 78 | - $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name; |
|
| 77 | + $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 78 | + $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name; |
|
| 79 | 79 | |
| 80 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 80 | + $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | 81 | |
| 82 | - /** controller/jobs/customer/email/account/decorators/excludes |
|
| 83 | - * Excludes decorators added by the "common" option from the customer email account controllers |
|
| 84 | - * |
|
| 85 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 86 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 87 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 88 | - * modify what is returned to the caller. |
|
| 89 | - * |
|
| 90 | - * This option allows you to remove a decorator added via |
|
| 91 | - * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 92 | - * around the job controller. |
|
| 93 | - * |
|
| 94 | - * controller/jobs/customer/email/account/decorators/excludes = array( 'decorator1' ) |
|
| 95 | - * |
|
| 96 | - * This would remove the decorator named "decorator1" from the list of |
|
| 97 | - * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 98 | - * "controller/jobs/common/decorators/default" to this job controller. |
|
| 99 | - * |
|
| 100 | - * @param array List of decorator names |
|
| 101 | - * @since 2016.04 |
|
| 102 | - * @category Developer |
|
| 103 | - * @see controller/jobs/common/decorators/default |
|
| 104 | - * @see controller/jobs/customer/email/account/decorators/global |
|
| 105 | - * @see controller/jobs/customer/email/account/decorators/local |
|
| 106 | - */ |
|
| 82 | + /** controller/jobs/customer/email/account/decorators/excludes |
|
| 83 | + * Excludes decorators added by the "common" option from the customer email account controllers |
|
| 84 | + * |
|
| 85 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 86 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 87 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 88 | + * modify what is returned to the caller. |
|
| 89 | + * |
|
| 90 | + * This option allows you to remove a decorator added via |
|
| 91 | + * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 92 | + * around the job controller. |
|
| 93 | + * |
|
| 94 | + * controller/jobs/customer/email/account/decorators/excludes = array( 'decorator1' ) |
|
| 95 | + * |
|
| 96 | + * This would remove the decorator named "decorator1" from the list of |
|
| 97 | + * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 98 | + * "controller/jobs/common/decorators/default" to this job controller. |
|
| 99 | + * |
|
| 100 | + * @param array List of decorator names |
|
| 101 | + * @since 2016.04 |
|
| 102 | + * @category Developer |
|
| 103 | + * @see controller/jobs/common/decorators/default |
|
| 104 | + * @see controller/jobs/customer/email/account/decorators/global |
|
| 105 | + * @see controller/jobs/customer/email/account/decorators/local |
|
| 106 | + */ |
|
| 107 | 107 | |
| 108 | - /** controller/jobs/customer/email/account/decorators/global |
|
| 109 | - * Adds a list of globally available decorators only to the customer email account controllers |
|
| 110 | - * |
|
| 111 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 112 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 113 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 114 | - * modify what is returned to the caller. |
|
| 115 | - * |
|
| 116 | - * This option allows you to wrap global decorators |
|
| 117 | - * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 118 | - * |
|
| 119 | - * controller/jobs/customer/email/account/decorators/global = array( 'decorator1' ) |
|
| 120 | - * |
|
| 121 | - * This would add the decorator named "decorator1" defined by |
|
| 122 | - * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 123 | - * |
|
| 124 | - * @param array List of decorator names |
|
| 125 | - * @since 2016.04 |
|
| 126 | - * @category Developer |
|
| 127 | - * @see controller/jobs/common/decorators/default |
|
| 128 | - * @see controller/jobs/customer/email/account/decorators/excludes |
|
| 129 | - * @see controller/jobs/customer/email/account/decorators/local |
|
| 130 | - */ |
|
| 108 | + /** controller/jobs/customer/email/account/decorators/global |
|
| 109 | + * Adds a list of globally available decorators only to the customer email account controllers |
|
| 110 | + * |
|
| 111 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 112 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 113 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 114 | + * modify what is returned to the caller. |
|
| 115 | + * |
|
| 116 | + * This option allows you to wrap global decorators |
|
| 117 | + * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 118 | + * |
|
| 119 | + * controller/jobs/customer/email/account/decorators/global = array( 'decorator1' ) |
|
| 120 | + * |
|
| 121 | + * This would add the decorator named "decorator1" defined by |
|
| 122 | + * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 123 | + * |
|
| 124 | + * @param array List of decorator names |
|
| 125 | + * @since 2016.04 |
|
| 126 | + * @category Developer |
|
| 127 | + * @see controller/jobs/common/decorators/default |
|
| 128 | + * @see controller/jobs/customer/email/account/decorators/excludes |
|
| 129 | + * @see controller/jobs/customer/email/account/decorators/local |
|
| 130 | + */ |
|
| 131 | 131 | |
| 132 | - /** controller/jobs/customer/email/account/decorators/local |
|
| 133 | - * Adds a list of local decorators only to the customer email account controllers |
|
| 134 | - * |
|
| 135 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 136 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 137 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 138 | - * modify what is returned to the caller. |
|
| 139 | - * |
|
| 140 | - * This option allows you to wrap local decorators |
|
| 141 | - * ("\Aimeos\Controller\Jobs\Customer\Email\Account\Decorator\*") around this job controller. |
|
| 142 | - * |
|
| 143 | - * controller/jobs/customer/email/account/decorators/local = array( 'decorator2' ) |
|
| 144 | - * |
|
| 145 | - * This would add the decorator named "decorator2" defined by |
|
| 146 | - * "\Aimeos\Controller\Jobs\Customer\Email\Account\Decorator\Decorator2" only to this job |
|
| 147 | - * controller. |
|
| 148 | - * |
|
| 149 | - * @param array List of decorator names |
|
| 150 | - * @since 2016.04 |
|
| 151 | - * @category Developer |
|
| 152 | - * @see controller/jobs/common/decorators/default |
|
| 153 | - * @see controller/jobs/customer/email/account/decorators/excludes |
|
| 154 | - * @see controller/jobs/customer/email/account/decorators/global |
|
| 155 | - */ |
|
| 156 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/account' ); |
|
| 157 | - } |
|
| 132 | + /** controller/jobs/customer/email/account/decorators/local |
|
| 133 | + * Adds a list of local decorators only to the customer email account controllers |
|
| 134 | + * |
|
| 135 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 136 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 137 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 138 | + * modify what is returned to the caller. |
|
| 139 | + * |
|
| 140 | + * This option allows you to wrap local decorators |
|
| 141 | + * ("\Aimeos\Controller\Jobs\Customer\Email\Account\Decorator\*") around this job controller. |
|
| 142 | + * |
|
| 143 | + * controller/jobs/customer/email/account/decorators/local = array( 'decorator2' ) |
|
| 144 | + * |
|
| 145 | + * This would add the decorator named "decorator2" defined by |
|
| 146 | + * "\Aimeos\Controller\Jobs\Customer\Email\Account\Decorator\Decorator2" only to this job |
|
| 147 | + * controller. |
|
| 148 | + * |
|
| 149 | + * @param array List of decorator names |
|
| 150 | + * @since 2016.04 |
|
| 151 | + * @category Developer |
|
| 152 | + * @see controller/jobs/common/decorators/default |
|
| 153 | + * @see controller/jobs/customer/email/account/decorators/excludes |
|
| 154 | + * @see controller/jobs/customer/email/account/decorators/global |
|
| 155 | + */ |
|
| 156 | + return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/account' ); |
|
| 157 | + } |
|
| 158 | 158 | } |
| 159 | 159 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string|null $name Name of the controller or "Standard" if null |
| 30 | 30 | * @return \Aimeos\Controller\Jobs\Iface New controller object |
| 31 | 31 | */ |
| 32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) |
|
| 33 | 33 | { |
| 34 | 34 | /** controller/jobs/customer/email/account/name |
| 35 | 35 | * Class name of the used product notification e-mail scheduler controller implementation |
@@ -64,20 +64,20 @@ discard block |
||
| 64 | 64 | * @since 2016.04 |
| 65 | 65 | * @category Developer |
| 66 | 66 | */ |
| 67 | - if( $name === null ) { |
|
| 68 | - $name = $context->getConfig()->get( 'controller/jobs/customer/email/account/name', 'Standard' ); |
|
| 67 | + if ($name === null) { |
|
| 68 | + $name = $context->getConfig()->get('controller/jobs/customer/email/account/name', 'Standard'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if( ctype_alnum( $name ) === false ) |
|
| 71 | + if (ctype_alnum($name) === false) |
|
| 72 | 72 | { |
| 73 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name : '<not a string>'; |
|
| 74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 73 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\'.$name : '<not a string>'; |
|
| 74 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
| 78 | - $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\' . $name; |
|
| 78 | + $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Account\\'.$name; |
|
| 79 | 79 | |
| 80 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 80 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); |
|
| 81 | 81 | |
| 82 | 82 | /** controller/jobs/customer/email/account/decorators/excludes |
| 83 | 83 | * Excludes decorators added by the "common" option from the customer email account controllers |
@@ -153,6 +153,6 @@ discard block |
||
| 153 | 153 | * @see controller/jobs/customer/email/account/decorators/excludes |
| 154 | 154 | * @see controller/jobs/customer/email/account/decorators/global |
| 155 | 155 | */ |
| 156 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/account' ); |
|
| 156 | + return self::addControllerDecorators($context, $aimeos, $controller, 'customer/email/account'); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | \ No newline at end of file |
@@ -18,111 +18,111 @@ |
||
| 18 | 18 | * @subpackage Jobs |
| 19 | 19 | */ |
| 20 | 20 | class Standard |
| 21 | - extends \Aimeos\Controller\Jobs\Base |
|
| 22 | - implements \Aimeos\Controller\Jobs\Iface |
|
| 21 | + extends \Aimeos\Controller\Jobs\Base |
|
| 22 | + implements \Aimeos\Controller\Jobs\Iface |
|
| 23 | 23 | { |
| 24 | - private $client; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Returns the localized name of the job. |
|
| 29 | - * |
|
| 30 | - * @return string Name of the job |
|
| 31 | - */ |
|
| 32 | - public function getName() |
|
| 33 | - { |
|
| 34 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Customer account e-mails' ); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Returns the localized description of the job. |
|
| 40 | - * |
|
| 41 | - * @return string Description of the job |
|
| 42 | - */ |
|
| 43 | - public function getDescription() |
|
| 44 | - { |
|
| 45 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for new customer accounts' ); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Executes the job. |
|
| 51 | - * |
|
| 52 | - * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 53 | - */ |
|
| 54 | - public function run() |
|
| 55 | - { |
|
| 56 | - $context = $this->getContext(); |
|
| 57 | - $queue = $context->getMessageQueue( 'mq-email', 'customer/email/account' ); |
|
| 58 | - $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 59 | - |
|
| 60 | - while( ( $msg = $queue->get() ) !== null ) |
|
| 61 | - { |
|
| 62 | - if( ( $list = json_decode( $msg->getBody(), true ) ) !== null ) |
|
| 63 | - { |
|
| 64 | - $item = $custManager->createItem(); |
|
| 65 | - $item->fromArray( $list ); |
|
| 66 | - |
|
| 67 | - $this->sendEmail( $context, $item ); |
|
| 68 | - } |
|
| 69 | - else |
|
| 70 | - { |
|
| 71 | - $context->getLogger()->log( sprintf( 'Invalid JSON encode message: %1$s', $msg->getBody() ) ); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $queue->del( $msg ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Returns the product notification e-mail client |
|
| 81 | - * |
|
| 82 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 83 | - * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
|
| 84 | - */ |
|
| 85 | - protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 86 | - { |
|
| 87 | - if( !isset( $this->client ) ) |
|
| 88 | - { |
|
| 89 | - $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 90 | - $this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient( $context, $templatePaths ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return $this->client; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Sends the account creation e-mail to the e-mail address of the customer |
|
| 99 | - * |
|
| 100 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 101 | - * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
|
| 102 | - */ |
|
| 103 | - protected function sendEmail( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item ) |
|
| 104 | - { |
|
| 105 | - $address = $item->getPaymentAddress(); |
|
| 106 | - |
|
| 107 | - $view = $context->getView(); |
|
| 108 | - $view->extAddressItem = $address; |
|
| 109 | - $view->extAccountCode = $item->getCode(); |
|
| 110 | - $view->extAccountPassword = $item->getPassword(); |
|
| 111 | - |
|
| 112 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 113 | - $view->addHelper( 'translate', $helper ); |
|
| 114 | - |
|
| 115 | - $mailer = $context->getMail(); |
|
| 116 | - $message = $mailer->createMessage(); |
|
| 117 | - |
|
| 118 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 119 | - $view->addHelper( 'mail', $helper ); |
|
| 120 | - |
|
| 121 | - $client = $this->getClient( $context ); |
|
| 122 | - $client->setView( $view ); |
|
| 123 | - $client->getHeader(); |
|
| 124 | - $client->getBody(); |
|
| 125 | - |
|
| 126 | - $mailer->send( $message ); |
|
| 127 | - } |
|
| 24 | + private $client; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Returns the localized name of the job. |
|
| 29 | + * |
|
| 30 | + * @return string Name of the job |
|
| 31 | + */ |
|
| 32 | + public function getName() |
|
| 33 | + { |
|
| 34 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Customer account e-mails' ); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Returns the localized description of the job. |
|
| 40 | + * |
|
| 41 | + * @return string Description of the job |
|
| 42 | + */ |
|
| 43 | + public function getDescription() |
|
| 44 | + { |
|
| 45 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for new customer accounts' ); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Executes the job. |
|
| 51 | + * |
|
| 52 | + * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 53 | + */ |
|
| 54 | + public function run() |
|
| 55 | + { |
|
| 56 | + $context = $this->getContext(); |
|
| 57 | + $queue = $context->getMessageQueue( 'mq-email', 'customer/email/account' ); |
|
| 58 | + $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 59 | + |
|
| 60 | + while( ( $msg = $queue->get() ) !== null ) |
|
| 61 | + { |
|
| 62 | + if( ( $list = json_decode( $msg->getBody(), true ) ) !== null ) |
|
| 63 | + { |
|
| 64 | + $item = $custManager->createItem(); |
|
| 65 | + $item->fromArray( $list ); |
|
| 66 | + |
|
| 67 | + $this->sendEmail( $context, $item ); |
|
| 68 | + } |
|
| 69 | + else |
|
| 70 | + { |
|
| 71 | + $context->getLogger()->log( sprintf( 'Invalid JSON encode message: %1$s', $msg->getBody() ) ); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $queue->del( $msg ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Returns the product notification e-mail client |
|
| 81 | + * |
|
| 82 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 83 | + * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
|
| 84 | + */ |
|
| 85 | + protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 86 | + { |
|
| 87 | + if( !isset( $this->client ) ) |
|
| 88 | + { |
|
| 89 | + $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 90 | + $this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient( $context, $templatePaths ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return $this->client; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Sends the account creation e-mail to the e-mail address of the customer |
|
| 99 | + * |
|
| 100 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 101 | + * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
|
| 102 | + */ |
|
| 103 | + protected function sendEmail( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item ) |
|
| 104 | + { |
|
| 105 | + $address = $item->getPaymentAddress(); |
|
| 106 | + |
|
| 107 | + $view = $context->getView(); |
|
| 108 | + $view->extAddressItem = $address; |
|
| 109 | + $view->extAccountCode = $item->getCode(); |
|
| 110 | + $view->extAccountPassword = $item->getPassword(); |
|
| 111 | + |
|
| 112 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 113 | + $view->addHelper( 'translate', $helper ); |
|
| 114 | + |
|
| 115 | + $mailer = $context->getMail(); |
|
| 116 | + $message = $mailer->createMessage(); |
|
| 117 | + |
|
| 118 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 119 | + $view->addHelper( 'mail', $helper ); |
|
| 120 | + |
|
| 121 | + $client = $this->getClient( $context ); |
|
| 122 | + $client->setView( $view ); |
|
| 123 | + $client->getHeader(); |
|
| 124 | + $client->getBody(); |
|
| 125 | + |
|
| 126 | + $mailer->send( $message ); |
|
| 127 | + } |
|
| 128 | 128 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function getName() |
| 33 | 33 | { |
| 34 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Customer account e-mails' ); |
|
| 34 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Customer account e-mails'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function getDescription() |
| 44 | 44 | { |
| 45 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for new customer accounts' ); |
|
| 45 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends e-mails for new customer accounts'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -54,24 +54,24 @@ discard block |
||
| 54 | 54 | public function run() |
| 55 | 55 | { |
| 56 | 56 | $context = $this->getContext(); |
| 57 | - $queue = $context->getMessageQueue( 'mq-email', 'customer/email/account' ); |
|
| 58 | - $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 57 | + $queue = $context->getMessageQueue('mq-email', 'customer/email/account'); |
|
| 58 | + $custManager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 59 | 59 | |
| 60 | - while( ( $msg = $queue->get() ) !== null ) |
|
| 60 | + while (($msg = $queue->get()) !== null) |
|
| 61 | 61 | { |
| 62 | - if( ( $list = json_decode( $msg->getBody(), true ) ) !== null ) |
|
| 62 | + if (($list = json_decode($msg->getBody(), true)) !== null) |
|
| 63 | 63 | { |
| 64 | 64 | $item = $custManager->createItem(); |
| 65 | - $item->fromArray( $list ); |
|
| 65 | + $item->fromArray($list); |
|
| 66 | 66 | |
| 67 | - $this->sendEmail( $context, $item ); |
|
| 67 | + $this->sendEmail($context, $item); |
|
| 68 | 68 | } |
| 69 | 69 | else |
| 70 | 70 | { |
| 71 | - $context->getLogger()->log( sprintf( 'Invalid JSON encode message: %1$s', $msg->getBody() ) ); |
|
| 71 | + $context->getLogger()->log(sprintf('Invalid JSON encode message: %1$s', $msg->getBody())); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $queue->del( $msg ); |
|
| 74 | + $queue->del($msg); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
| 83 | 83 | * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
| 84 | 84 | */ |
| 85 | - protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 85 | + protected function getClient(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 86 | 86 | { |
| 87 | - if( !isset( $this->client ) ) |
|
| 87 | + if (!isset($this->client)) |
|
| 88 | 88 | { |
| 89 | - $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 90 | - $this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient( $context, $templatePaths ); |
|
| 89 | + $templatePaths = $this->getAimeos()->getCustomPaths('client/html'); |
|
| 90 | + $this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient($context, $templatePaths); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $this->client; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
| 101 | 101 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
| 102 | 102 | */ |
| 103 | - protected function sendEmail( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item ) |
|
| 103 | + protected function sendEmail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item) |
|
| 104 | 104 | { |
| 105 | 105 | $address = $item->getPaymentAddress(); |
| 106 | 106 | |
@@ -109,20 +109,20 @@ discard block |
||
| 109 | 109 | $view->extAccountCode = $item->getCode(); |
| 110 | 110 | $view->extAccountPassword = $item->getPassword(); |
| 111 | 111 | |
| 112 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 113 | - $view->addHelper( 'translate', $helper ); |
|
| 112 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId())); |
|
| 113 | + $view->addHelper('translate', $helper); |
|
| 114 | 114 | |
| 115 | 115 | $mailer = $context->getMail(); |
| 116 | 116 | $message = $mailer->createMessage(); |
| 117 | 117 | |
| 118 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 119 | - $view->addHelper( 'mail', $helper ); |
|
| 118 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); |
|
| 119 | + $view->addHelper('mail', $helper); |
|
| 120 | 120 | |
| 121 | - $client = $this->getClient( $context ); |
|
| 122 | - $client->setView( $view ); |
|
| 121 | + $client = $this->getClient($context); |
|
| 122 | + $client->setView($view); |
|
| 123 | 123 | $client->getHeader(); |
| 124 | 124 | $client->getBody(); |
| 125 | 125 | |
| 126 | - $mailer->send( $message ); |
|
| 126 | + $mailer->send($message); |
|
| 127 | 127 | } |
| 128 | 128 | } |
@@ -341,8 +341,7 @@ |
||
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | $attrMap = $sortedMap; |
| 344 | - } |
|
| 345 | - else |
|
| 344 | + } else |
|
| 346 | 345 | { |
| 347 | 346 | ksort( $attrMap ); |
| 348 | 347 | } |
@@ -19,141 +19,141 @@ |
||
| 19 | 19 | * @subpackage Customer |
| 20 | 20 | */ |
| 21 | 21 | class Factory |
| 22 | - extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Creates a new controller specified by the given name. |
|
| 27 | - * |
|
| 28 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | - * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | - * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | - * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | - */ |
|
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | - { |
|
| 35 | - /** controller/jobs/customer/email/watch/name |
|
| 36 | - * Class name of the used product notification e-mail scheduler controller implementation |
|
| 37 | - * |
|
| 38 | - * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | - * To use this implementation, you have to set the last part of the class |
|
| 40 | - * name as configuration value so the controller factory knows which class it |
|
| 41 | - * has to instantiate. |
|
| 42 | - * |
|
| 43 | - * For example, if the name of the default class is |
|
| 44 | - * |
|
| 45 | - * \Aimeos\Controller\Jobs\Customer\Email\Watch\Standard |
|
| 46 | - * |
|
| 47 | - * and you want to replace it with your own version named |
|
| 48 | - * |
|
| 49 | - * \Aimeos\Controller\Jobs\Customer\Email\Watch\Mywatch |
|
| 50 | - * |
|
| 51 | - * then you have to set the this configuration option: |
|
| 52 | - * |
|
| 53 | - * controller/jobs/customer/email/watch/name = Mywatch |
|
| 54 | - * |
|
| 55 | - * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | - * so take care that the configuration value is exactly named like the last |
|
| 57 | - * part of the class name. |
|
| 58 | - * |
|
| 59 | - * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | - * characters are possible! You should always start the last part of the class |
|
| 61 | - * name with an upper case character and continue only with lower case characters |
|
| 62 | - * or numbers. Avoid chamel case names like "MyWatch"! |
|
| 63 | - * |
|
| 64 | - * @param string Last part of the class name |
|
| 65 | - * @since 2014.03 |
|
| 66 | - * @category Developer |
|
| 67 | - */ |
|
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/customer/email/watch/name', 'Standard' ); |
|
| 70 | - } |
|
| 25 | + /** |
|
| 26 | + * Creates a new controller specified by the given name. |
|
| 27 | + * |
|
| 28 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
| 29 | + * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
| 30 | + * @param string|null $name Name of the controller or "Standard" if null |
|
| 31 | + * @return \Aimeos\Controller\Jobs\Iface New controller object |
|
| 32 | + */ |
|
| 33 | + public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 34 | + { |
|
| 35 | + /** controller/jobs/customer/email/watch/name |
|
| 36 | + * Class name of the used product notification e-mail scheduler controller implementation |
|
| 37 | + * |
|
| 38 | + * Each default job controller can be replace by an alternative imlementation. |
|
| 39 | + * To use this implementation, you have to set the last part of the class |
|
| 40 | + * name as configuration value so the controller factory knows which class it |
|
| 41 | + * has to instantiate. |
|
| 42 | + * |
|
| 43 | + * For example, if the name of the default class is |
|
| 44 | + * |
|
| 45 | + * \Aimeos\Controller\Jobs\Customer\Email\Watch\Standard |
|
| 46 | + * |
|
| 47 | + * and you want to replace it with your own version named |
|
| 48 | + * |
|
| 49 | + * \Aimeos\Controller\Jobs\Customer\Email\Watch\Mywatch |
|
| 50 | + * |
|
| 51 | + * then you have to set the this configuration option: |
|
| 52 | + * |
|
| 53 | + * controller/jobs/customer/email/watch/name = Mywatch |
|
| 54 | + * |
|
| 55 | + * The value is the last part of your own class name and it's case sensitive, |
|
| 56 | + * so take care that the configuration value is exactly named like the last |
|
| 57 | + * part of the class name. |
|
| 58 | + * |
|
| 59 | + * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 60 | + * characters are possible! You should always start the last part of the class |
|
| 61 | + * name with an upper case character and continue only with lower case characters |
|
| 62 | + * or numbers. Avoid chamel case names like "MyWatch"! |
|
| 63 | + * |
|
| 64 | + * @param string Last part of the class name |
|
| 65 | + * @since 2014.03 |
|
| 66 | + * @category Developer |
|
| 67 | + */ |
|
| 68 | + if( $name === null ) { |
|
| 69 | + $name = $context->getConfig()->get( 'controller/jobs/customer/email/watch/name', 'Standard' ); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 73 | - { |
|
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | - } |
|
| 72 | + if( ctype_alnum( $name ) === false ) |
|
| 73 | + { |
|
| 74 | + $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name; |
|
| 78 | + $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 82 | 82 | |
| 83 | - /** controller/jobs/customer/email/watch/decorators/excludes |
|
| 84 | - * Excludes decorators added by the "common" option from the customer email watch controllers |
|
| 85 | - * |
|
| 86 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | - * modify what is returned to the caller. |
|
| 90 | - * |
|
| 91 | - * This option allows you to remove a decorator added via |
|
| 92 | - * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | - * around the job controller. |
|
| 94 | - * |
|
| 95 | - * controller/jobs/customer/email/watch/decorators/excludes = array( 'decorator1' ) |
|
| 96 | - * |
|
| 97 | - * This would remove the decorator named "decorator1" from the list of |
|
| 98 | - * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | - * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | - * |
|
| 101 | - * @param array List of decorator names |
|
| 102 | - * @since 2015.09 |
|
| 103 | - * @category Developer |
|
| 104 | - * @see controller/jobs/common/decorators/default |
|
| 105 | - * @see controller/jobs/customer/email/watch/decorators/global |
|
| 106 | - * @see controller/jobs/customer/email/watch/decorators/local |
|
| 107 | - */ |
|
| 83 | + /** controller/jobs/customer/email/watch/decorators/excludes |
|
| 84 | + * Excludes decorators added by the "common" option from the customer email watch controllers |
|
| 85 | + * |
|
| 86 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 87 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 88 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 89 | + * modify what is returned to the caller. |
|
| 90 | + * |
|
| 91 | + * This option allows you to remove a decorator added via |
|
| 92 | + * "controller/jobs/common/decorators/default" before they are wrapped |
|
| 93 | + * around the job controller. |
|
| 94 | + * |
|
| 95 | + * controller/jobs/customer/email/watch/decorators/excludes = array( 'decorator1' ) |
|
| 96 | + * |
|
| 97 | + * This would remove the decorator named "decorator1" from the list of |
|
| 98 | + * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
| 99 | + * "controller/jobs/common/decorators/default" to this job controller. |
|
| 100 | + * |
|
| 101 | + * @param array List of decorator names |
|
| 102 | + * @since 2015.09 |
|
| 103 | + * @category Developer |
|
| 104 | + * @see controller/jobs/common/decorators/default |
|
| 105 | + * @see controller/jobs/customer/email/watch/decorators/global |
|
| 106 | + * @see controller/jobs/customer/email/watch/decorators/local |
|
| 107 | + */ |
|
| 108 | 108 | |
| 109 | - /** controller/jobs/customer/email/watch/decorators/global |
|
| 110 | - * Adds a list of globally available decorators only to the customer email watch controllers |
|
| 111 | - * |
|
| 112 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | - * modify what is returned to the caller. |
|
| 116 | - * |
|
| 117 | - * This option allows you to wrap global decorators |
|
| 118 | - * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | - * |
|
| 120 | - * controller/jobs/customer/email/watch/decorators/global = array( 'decorator1' ) |
|
| 121 | - * |
|
| 122 | - * This would add the decorator named "decorator1" defined by |
|
| 123 | - * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | - * |
|
| 125 | - * @param array List of decorator names |
|
| 126 | - * @since 2015.09 |
|
| 127 | - * @category Developer |
|
| 128 | - * @see controller/jobs/common/decorators/default |
|
| 129 | - * @see controller/jobs/customer/email/watch/decorators/excludes |
|
| 130 | - * @see controller/jobs/customer/email/watch/decorators/local |
|
| 131 | - */ |
|
| 109 | + /** controller/jobs/customer/email/watch/decorators/global |
|
| 110 | + * Adds a list of globally available decorators only to the customer email watch controllers |
|
| 111 | + * |
|
| 112 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 113 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 114 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 115 | + * modify what is returned to the caller. |
|
| 116 | + * |
|
| 117 | + * This option allows you to wrap global decorators |
|
| 118 | + * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
| 119 | + * |
|
| 120 | + * controller/jobs/customer/email/watch/decorators/global = array( 'decorator1' ) |
|
| 121 | + * |
|
| 122 | + * This would add the decorator named "decorator1" defined by |
|
| 123 | + * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
|
| 124 | + * |
|
| 125 | + * @param array List of decorator names |
|
| 126 | + * @since 2015.09 |
|
| 127 | + * @category Developer |
|
| 128 | + * @see controller/jobs/common/decorators/default |
|
| 129 | + * @see controller/jobs/customer/email/watch/decorators/excludes |
|
| 130 | + * @see controller/jobs/customer/email/watch/decorators/local |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | - /** controller/jobs/customer/email/watch/decorators/local |
|
| 134 | - * Adds a list of local decorators only to the customer email watch controllers |
|
| 135 | - * |
|
| 136 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | - * modify what is returned to the caller. |
|
| 140 | - * |
|
| 141 | - * This option allows you to wrap local decorators |
|
| 142 | - * ("\Aimeos\Controller\Jobs\Customer\Email\Watch\Decorator\*") around this job controller. |
|
| 143 | - * |
|
| 144 | - * controller/jobs/customer/email/watch/decorators/local = array( 'decorator2' ) |
|
| 145 | - * |
|
| 146 | - * This would add the decorator named "decorator2" defined by |
|
| 147 | - * "\Aimeos\Controller\Jobs\Customer\Email\Watch\Decorator\Decorator2" only to this job |
|
| 148 | - * controller. |
|
| 149 | - * |
|
| 150 | - * @param array List of decorator names |
|
| 151 | - * @since 2015.09 |
|
| 152 | - * @category Developer |
|
| 153 | - * @see controller/jobs/common/decorators/default |
|
| 154 | - * @see controller/jobs/customer/email/watch/decorators/excludes |
|
| 155 | - * @see controller/jobs/customer/email/watch/decorators/global |
|
| 156 | - */ |
|
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/watch' ); |
|
| 158 | - } |
|
| 133 | + /** controller/jobs/customer/email/watch/decorators/local |
|
| 134 | + * Adds a list of local decorators only to the customer email watch controllers |
|
| 135 | + * |
|
| 136 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 137 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 138 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 139 | + * modify what is returned to the caller. |
|
| 140 | + * |
|
| 141 | + * This option allows you to wrap local decorators |
|
| 142 | + * ("\Aimeos\Controller\Jobs\Customer\Email\Watch\Decorator\*") around this job controller. |
|
| 143 | + * |
|
| 144 | + * controller/jobs/customer/email/watch/decorators/local = array( 'decorator2' ) |
|
| 145 | + * |
|
| 146 | + * This would add the decorator named "decorator2" defined by |
|
| 147 | + * "\Aimeos\Controller\Jobs\Customer\Email\Watch\Decorator\Decorator2" only to this job |
|
| 148 | + * controller. |
|
| 149 | + * |
|
| 150 | + * @param array List of decorator names |
|
| 151 | + * @since 2015.09 |
|
| 152 | + * @category Developer |
|
| 153 | + * @see controller/jobs/common/decorators/default |
|
| 154 | + * @see controller/jobs/customer/email/watch/decorators/excludes |
|
| 155 | + * @see controller/jobs/customer/email/watch/decorators/global |
|
| 156 | + */ |
|
| 157 | + return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/watch' ); |
|
| 158 | + } |
|
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string|null $name Name of the controller or "Standard" if null |
| 31 | 31 | * @return \Aimeos\Controller\Jobs\Iface New controller object |
| 32 | 32 | */ |
| 33 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
| 33 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) |
|
| 34 | 34 | { |
| 35 | 35 | /** controller/jobs/customer/email/watch/name |
| 36 | 36 | * Class name of the used product notification e-mail scheduler controller implementation |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | * @since 2014.03 |
| 66 | 66 | * @category Developer |
| 67 | 67 | */ |
| 68 | - if( $name === null ) { |
|
| 69 | - $name = $context->getConfig()->get( 'controller/jobs/customer/email/watch/name', 'Standard' ); |
|
| 68 | + if ($name === null) { |
|
| 69 | + $name = $context->getConfig()->get('controller/jobs/customer/email/watch/name', 'Standard'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( ctype_alnum( $name ) === false ) |
|
| 72 | + if (ctype_alnum($name) === false) |
|
| 73 | 73 | { |
| 74 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name : '<not a string>'; |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 74 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\'.$name : '<not a string>'; |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
| 79 | - $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\' . $name; |
|
| 79 | + $classname = '\\Aimeos\\Controller\\Jobs\\Customer\\Email\\Watch\\'.$name; |
|
| 80 | 80 | |
| 81 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
| 81 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); |
|
| 82 | 82 | |
| 83 | 83 | /** controller/jobs/customer/email/watch/decorators/excludes |
| 84 | 84 | * Excludes decorators added by the "common" option from the customer email watch controllers |
@@ -154,6 +154,6 @@ discard block |
||
| 154 | 154 | * @see controller/jobs/customer/email/watch/decorators/excludes |
| 155 | 155 | * @see controller/jobs/customer/email/watch/decorators/global |
| 156 | 156 | */ |
| 157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'customer/email/watch' ); |
|
| 157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'customer/email/watch'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | \ No newline at end of file |
@@ -19,346 +19,346 @@ |
||
| 19 | 19 | * @subpackage Customer |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Controller\Jobs\Base |
|
| 23 | - implements \Aimeos\Controller\Jobs\Iface |
|
| 22 | + extends \Aimeos\Controller\Jobs\Base |
|
| 23 | + implements \Aimeos\Controller\Jobs\Iface |
|
| 24 | 24 | { |
| 25 | - private $client; |
|
| 26 | - private $warehouses; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Returns the localized name of the job. |
|
| 31 | - * |
|
| 32 | - * @return string Name of the job |
|
| 33 | - */ |
|
| 34 | - public function getName() |
|
| 35 | - { |
|
| 36 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product notification e-mails' ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Returns the localized description of the job. |
|
| 42 | - * |
|
| 43 | - * @return string Description of the job |
|
| 44 | - */ |
|
| 45 | - public function getDescription() |
|
| 46 | - { |
|
| 47 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for watched products' ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Executes the job. |
|
| 53 | - * |
|
| 54 | - * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 55 | - */ |
|
| 56 | - public function run() |
|
| 57 | - { |
|
| 58 | - $langIds = array(); |
|
| 59 | - $context = $this->getContext(); |
|
| 60 | - $typeId = $this->getListTypeItem( 'watch' )->getId(); |
|
| 61 | - |
|
| 62 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 63 | - $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 64 | - |
|
| 65 | - $localeItems = $localeManager->searchItems( $localeManager->createSearch() ); |
|
| 66 | - |
|
| 67 | - foreach( $localeItems as $localeItem ) |
|
| 68 | - { |
|
| 69 | - $langId = $localeItem->getLanguageId(); |
|
| 70 | - |
|
| 71 | - if( isset( $langIds[$langId] ) ) { |
|
| 72 | - continue; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $langIds[$langId] = true; |
|
| 76 | - // fetch language specific text and media items for products |
|
| 77 | - $context->getLocale()->setLanguageId( $langId ); |
|
| 78 | - |
|
| 79 | - $search = $custManager->createSearch( true ); |
|
| 80 | - $expr = array( |
|
| 81 | - $search->compare( '==', 'customer.languageid', $langId ), |
|
| 82 | - $search->compare( '==', 'customer.lists.typeid', $typeId ), |
|
| 83 | - $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 84 | - $search->getConditions(), |
|
| 85 | - ); |
|
| 86 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 87 | - $search->setSortations( array( $search->sort( '+', 'customer.id' ) ) ); |
|
| 88 | - |
|
| 89 | - $start = 0; |
|
| 90 | - |
|
| 91 | - do |
|
| 92 | - { |
|
| 93 | - $customers = $custManager->searchItems( $search ); |
|
| 94 | - |
|
| 95 | - $this->execute( $context, $customers, $typeId ); |
|
| 96 | - |
|
| 97 | - $count = count( $customers ); |
|
| 98 | - $start += $count; |
|
| 99 | - $search->setSlice( $start ); |
|
| 100 | - } |
|
| 101 | - while( $count >= $search->getSliceSize() ); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Sends product notifications for the given customers in their language |
|
| 108 | - * |
|
| 109 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 110 | - * @param array $customers List of customer items implementing \Aimeos\MShop\Customer\Item\Iface |
|
| 111 | - * @param string $listTypeId Customer list type ID |
|
| 112 | - */ |
|
| 113 | - protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers, $listTypeId ) |
|
| 114 | - { |
|
| 115 | - $prodIds = $custIds = array(); |
|
| 116 | - $whItem = $this->getWarehouseItem( 'default' ); |
|
| 117 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 118 | - $listItems = $this->getListItems( $context, array_keys( $customers ), $listTypeId ); |
|
| 119 | - |
|
| 120 | - foreach( $listItems as $id => $listItem ) |
|
| 121 | - { |
|
| 122 | - $refId = $listItem->getRefId(); |
|
| 123 | - $custIds[ $listItem->getParentId() ][$id] = $refId; |
|
| 124 | - $prodIds[$refId] = $refId; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $date = date( 'Y-m-d H:i:s' ); |
|
| 128 | - $products = $this->getProducts( $context, $prodIds, $whItem->getId() ); |
|
| 129 | - |
|
| 130 | - foreach( $custIds as $custId => $list ) |
|
| 131 | - { |
|
| 132 | - $custListItems = $listIds = array(); |
|
| 133 | - |
|
| 134 | - foreach( $list as $listId => $prodId ) |
|
| 135 | - { |
|
| 136 | - $listItem = $listItems[$listId]; |
|
| 137 | - |
|
| 138 | - if( $listItem->getDateEnd() < $date ) { |
|
| 139 | - $listIds[] = $listId; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $custListItems[$listId] = $listItems[$listId]; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - try |
|
| 146 | - { |
|
| 147 | - $custProducts = $this->getListProducts( $custListItems, $products ); |
|
| 148 | - |
|
| 149 | - if( !empty( $custProducts ) ) |
|
| 150 | - { |
|
| 151 | - $this->sendMail( $context, $customers[$custId]->getPaymentAddress(), $custProducts ); |
|
| 152 | - $listIds += array_keys( $custProducts ); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - catch( \Exception $e ) |
|
| 156 | - { |
|
| 157 | - $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; |
|
| 158 | - $msg = sprintf( $str, $custId, $e->getMessage() ); |
|
| 159 | - $context->getLogger()->log( $msg ); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $listManager->deleteItems( $listIds ); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Returns the product notification e-mail client |
|
| 169 | - * |
|
| 170 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 171 | - * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
|
| 172 | - */ |
|
| 173 | - protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 174 | - { |
|
| 175 | - if( !isset( $this->client ) ) |
|
| 176 | - { |
|
| 177 | - $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 178 | - $this->client = \Aimeos\Client\Html\Email\Watch\Factory::createClient( $context, $templatePaths ); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return $this->client; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Returns the list items for the given customer IDs and list type ID |
|
| 187 | - * |
|
| 188 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 189 | - * @param array $custIds List of customer IDs |
|
| 190 | - * @param string $listTypeId Customer list type ID |
|
| 191 | - * @return array List of customer list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
|
| 192 | - */ |
|
| 193 | - protected function getListItems( \Aimeos\MShop\Context\Item\Iface $context, array $custIds, $listTypeId ) |
|
| 194 | - { |
|
| 195 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 196 | - |
|
| 197 | - $search = $listManager->createSearch(); |
|
| 198 | - $expr = array( |
|
| 199 | - $search->compare( '==', 'customer.lists.parentid', $custIds ), |
|
| 200 | - $search->compare( '==', 'customer.lists.typeid', $listTypeId ), |
|
| 201 | - $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 202 | - ); |
|
| 203 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 204 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 205 | - |
|
| 206 | - return $listManager->searchItems( $search ); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Returns a filtered list of products for which a notification should be sent |
|
| 212 | - * |
|
| 213 | - * @param array $listItems List of customer list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
|
| 214 | - * @param array $products List of product items implementing \Aimeos\MShop\Product\Item\Iface |
|
| 215 | - * @return array Multi-dimensional associative list of list IDs as key and product / price item maps as values |
|
| 216 | - */ |
|
| 217 | - protected function getListProducts( array $listItems, array $products ) |
|
| 218 | - { |
|
| 219 | - $result = array(); |
|
| 220 | - $priceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
| 221 | - |
|
| 222 | - foreach( $listItems as $id => $listItem ) |
|
| 223 | - { |
|
| 224 | - try |
|
| 225 | - { |
|
| 226 | - $refId = $listItem->getRefId(); |
|
| 227 | - $config = $listItem->getConfig(); |
|
| 228 | - |
|
| 229 | - if( isset( $products[$refId] ) ) |
|
| 230 | - { |
|
| 231 | - $prices = $products[$refId]->getRefItems( 'price', 'default', 'default' ); |
|
| 232 | - $currencyId = ( isset( $config['currency'] ) ? $config['currency'] : null ); |
|
| 233 | - |
|
| 234 | - $price = $priceManager->getLowestPrice( $prices, 1, $currencyId ); |
|
| 235 | - |
|
| 236 | - if( isset( $config['stock'] ) && $config['stock'] == 1 || |
|
| 237 | - isset( $config['price'] ) && $config['price'] == 1 && |
|
| 238 | - isset( $config['pricevalue'] ) && $config['pricevalue'] > $price->getValue() |
|
| 239 | - ) { |
|
| 240 | - $result[$id]['item'] = $products[$refId]; |
|
| 241 | - $result[$id]['price'] = $price; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - catch( \Exception $e ) { ; } // no price available |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - return $result; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Returns the products for the given IDs which are in stock in the warehouse |
|
| 254 | - * |
|
| 255 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 256 | - * @param array $prodIds List of product IDs |
|
| 257 | - * @param string $whId Unique warehouse ID |
|
| 258 | - */ |
|
| 259 | - protected function getProducts( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds, $whId ) |
|
| 260 | - { |
|
| 261 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 262 | - $search = $productManager->createSearch( true ); |
|
| 263 | - $domains = array( 'text', 'price', 'media' ); |
|
| 264 | - |
|
| 265 | - $stockExpr = array( |
|
| 266 | - $search->compare( '==', 'product.stock.stocklevel', null ), |
|
| 267 | - $search->compare( '>', 'product.stock.stocklevel', 0 ), |
|
| 268 | - ); |
|
| 269 | - |
|
| 270 | - $expr = array( |
|
| 271 | - $search->compare( '==', 'product.id', $prodIds ), |
|
| 272 | - $search->getConditions(), |
|
| 273 | - $search->compare( '==', 'product.stock.warehouseid', $whId ), |
|
| 274 | - $search->combine( '||', $stockExpr ), |
|
| 275 | - ); |
|
| 276 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 277 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 278 | - |
|
| 279 | - return $productManager->searchItems( $search, $domains ); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Returns the customer list type item for the given type code. |
|
| 285 | - * |
|
| 286 | - * @param string $code Unique code of the list type item |
|
| 287 | - * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
|
| 288 | - * @throws \Aimeos\Controller\Jobs\Exception If the list type item wasn't found |
|
| 289 | - */ |
|
| 290 | - protected function getListTypeItem( $code ) |
|
| 291 | - { |
|
| 292 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists/type' ); |
|
| 293 | - |
|
| 294 | - $search = $manager->createSearch( true ); |
|
| 295 | - $search->setConditions( $search->compare( '==', 'customer.lists.type.code', $code ) ); |
|
| 296 | - $result = $manager->searchItems( $search ); |
|
| 297 | - |
|
| 298 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 299 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'List type for domain "%1$s" and code "%2$s" not found', 'customer', $code ) ); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - return $item; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Returns the warehouse item for the given code. |
|
| 308 | - * |
|
| 309 | - * @param string $code Unique code of the warehouse item |
|
| 310 | - * @return \Aimeos\MShop\Product\Item\Stock\Warehouse\Iface Warehouse item |
|
| 311 | - * @throws \Aimeos\Controller\Jobs\Exception If the warehouse item wasn't found |
|
| 312 | - */ |
|
| 313 | - protected function getWarehouseItem( $code ) |
|
| 314 | - { |
|
| 315 | - if( !isset( $this->warehouses ) ) |
|
| 316 | - { |
|
| 317 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock/warehouse' ); |
|
| 318 | - $search = $manager->createSearch( true ); |
|
| 319 | - |
|
| 320 | - $this->warehouses = array(); |
|
| 321 | - foreach( $manager->searchItems( $search ) as $whItem ) { |
|
| 322 | - $this->warehouses[ $whItem->getCode() ] = $whItem; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - if( !isset( $this->warehouses[$code] ) ) { |
|
| 327 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No warehouse "%1$s" found', $code ) ); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - return $this->warehouses[$code]; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Sends the notification e-mail for the given customer address and products |
|
| 336 | - * |
|
| 337 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 338 | - * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address of the customer |
|
| 339 | - * @param array $products List of products a notification should be sent for |
|
| 340 | - */ |
|
| 341 | - protected function sendMail( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 342 | - \Aimeos\MShop\Common\Item\Address\Iface $address, array $products ) |
|
| 343 | - { |
|
| 344 | - $view = $context->getView(); |
|
| 345 | - $view->extProducts = $products; |
|
| 346 | - $view->extAddressItem = $address; |
|
| 347 | - |
|
| 348 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 349 | - $view->addHelper( 'translate', $helper ); |
|
| 350 | - |
|
| 351 | - $mailer = $context->getMail(); |
|
| 352 | - $message = $mailer->createMessage(); |
|
| 353 | - |
|
| 354 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 355 | - $view->addHelper( 'mail', $helper ); |
|
| 356 | - |
|
| 357 | - $client = $this->getClient( $context ); |
|
| 358 | - $client->setView( $view ); |
|
| 359 | - $client->getHeader(); |
|
| 360 | - $client->getBody(); |
|
| 361 | - |
|
| 362 | - $mailer->send( $message ); |
|
| 363 | - } |
|
| 25 | + private $client; |
|
| 26 | + private $warehouses; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Returns the localized name of the job. |
|
| 31 | + * |
|
| 32 | + * @return string Name of the job |
|
| 33 | + */ |
|
| 34 | + public function getName() |
|
| 35 | + { |
|
| 36 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product notification e-mails' ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Returns the localized description of the job. |
|
| 42 | + * |
|
| 43 | + * @return string Description of the job |
|
| 44 | + */ |
|
| 45 | + public function getDescription() |
|
| 46 | + { |
|
| 47 | + return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for watched products' ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Executes the job. |
|
| 53 | + * |
|
| 54 | + * @throws \Aimeos\Controller\Jobs\Exception If an error occurs |
|
| 55 | + */ |
|
| 56 | + public function run() |
|
| 57 | + { |
|
| 58 | + $langIds = array(); |
|
| 59 | + $context = $this->getContext(); |
|
| 60 | + $typeId = $this->getListTypeItem( 'watch' )->getId(); |
|
| 61 | + |
|
| 62 | + $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 63 | + $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 64 | + |
|
| 65 | + $localeItems = $localeManager->searchItems( $localeManager->createSearch() ); |
|
| 66 | + |
|
| 67 | + foreach( $localeItems as $localeItem ) |
|
| 68 | + { |
|
| 69 | + $langId = $localeItem->getLanguageId(); |
|
| 70 | + |
|
| 71 | + if( isset( $langIds[$langId] ) ) { |
|
| 72 | + continue; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $langIds[$langId] = true; |
|
| 76 | + // fetch language specific text and media items for products |
|
| 77 | + $context->getLocale()->setLanguageId( $langId ); |
|
| 78 | + |
|
| 79 | + $search = $custManager->createSearch( true ); |
|
| 80 | + $expr = array( |
|
| 81 | + $search->compare( '==', 'customer.languageid', $langId ), |
|
| 82 | + $search->compare( '==', 'customer.lists.typeid', $typeId ), |
|
| 83 | + $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 84 | + $search->getConditions(), |
|
| 85 | + ); |
|
| 86 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 87 | + $search->setSortations( array( $search->sort( '+', 'customer.id' ) ) ); |
|
| 88 | + |
|
| 89 | + $start = 0; |
|
| 90 | + |
|
| 91 | + do |
|
| 92 | + { |
|
| 93 | + $customers = $custManager->searchItems( $search ); |
|
| 94 | + |
|
| 95 | + $this->execute( $context, $customers, $typeId ); |
|
| 96 | + |
|
| 97 | + $count = count( $customers ); |
|
| 98 | + $start += $count; |
|
| 99 | + $search->setSlice( $start ); |
|
| 100 | + } |
|
| 101 | + while( $count >= $search->getSliceSize() ); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Sends product notifications for the given customers in their language |
|
| 108 | + * |
|
| 109 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 110 | + * @param array $customers List of customer items implementing \Aimeos\MShop\Customer\Item\Iface |
|
| 111 | + * @param string $listTypeId Customer list type ID |
|
| 112 | + */ |
|
| 113 | + protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers, $listTypeId ) |
|
| 114 | + { |
|
| 115 | + $prodIds = $custIds = array(); |
|
| 116 | + $whItem = $this->getWarehouseItem( 'default' ); |
|
| 117 | + $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 118 | + $listItems = $this->getListItems( $context, array_keys( $customers ), $listTypeId ); |
|
| 119 | + |
|
| 120 | + foreach( $listItems as $id => $listItem ) |
|
| 121 | + { |
|
| 122 | + $refId = $listItem->getRefId(); |
|
| 123 | + $custIds[ $listItem->getParentId() ][$id] = $refId; |
|
| 124 | + $prodIds[$refId] = $refId; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $date = date( 'Y-m-d H:i:s' ); |
|
| 128 | + $products = $this->getProducts( $context, $prodIds, $whItem->getId() ); |
|
| 129 | + |
|
| 130 | + foreach( $custIds as $custId => $list ) |
|
| 131 | + { |
|
| 132 | + $custListItems = $listIds = array(); |
|
| 133 | + |
|
| 134 | + foreach( $list as $listId => $prodId ) |
|
| 135 | + { |
|
| 136 | + $listItem = $listItems[$listId]; |
|
| 137 | + |
|
| 138 | + if( $listItem->getDateEnd() < $date ) { |
|
| 139 | + $listIds[] = $listId; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $custListItems[$listId] = $listItems[$listId]; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + try |
|
| 146 | + { |
|
| 147 | + $custProducts = $this->getListProducts( $custListItems, $products ); |
|
| 148 | + |
|
| 149 | + if( !empty( $custProducts ) ) |
|
| 150 | + { |
|
| 151 | + $this->sendMail( $context, $customers[$custId]->getPaymentAddress(), $custProducts ); |
|
| 152 | + $listIds += array_keys( $custProducts ); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + catch( \Exception $e ) |
|
| 156 | + { |
|
| 157 | + $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; |
|
| 158 | + $msg = sprintf( $str, $custId, $e->getMessage() ); |
|
| 159 | + $context->getLogger()->log( $msg ); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $listManager->deleteItems( $listIds ); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Returns the product notification e-mail client |
|
| 169 | + * |
|
| 170 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 171 | + * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
|
| 172 | + */ |
|
| 173 | + protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 174 | + { |
|
| 175 | + if( !isset( $this->client ) ) |
|
| 176 | + { |
|
| 177 | + $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 178 | + $this->client = \Aimeos\Client\Html\Email\Watch\Factory::createClient( $context, $templatePaths ); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return $this->client; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Returns the list items for the given customer IDs and list type ID |
|
| 187 | + * |
|
| 188 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 189 | + * @param array $custIds List of customer IDs |
|
| 190 | + * @param string $listTypeId Customer list type ID |
|
| 191 | + * @return array List of customer list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
|
| 192 | + */ |
|
| 193 | + protected function getListItems( \Aimeos\MShop\Context\Item\Iface $context, array $custIds, $listTypeId ) |
|
| 194 | + { |
|
| 195 | + $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 196 | + |
|
| 197 | + $search = $listManager->createSearch(); |
|
| 198 | + $expr = array( |
|
| 199 | + $search->compare( '==', 'customer.lists.parentid', $custIds ), |
|
| 200 | + $search->compare( '==', 'customer.lists.typeid', $listTypeId ), |
|
| 201 | + $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 202 | + ); |
|
| 203 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 204 | + $search->setSlice( 0, 0x7fffffff ); |
|
| 205 | + |
|
| 206 | + return $listManager->searchItems( $search ); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Returns a filtered list of products for which a notification should be sent |
|
| 212 | + * |
|
| 213 | + * @param array $listItems List of customer list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
|
| 214 | + * @param array $products List of product items implementing \Aimeos\MShop\Product\Item\Iface |
|
| 215 | + * @return array Multi-dimensional associative list of list IDs as key and product / price item maps as values |
|
| 216 | + */ |
|
| 217 | + protected function getListProducts( array $listItems, array $products ) |
|
| 218 | + { |
|
| 219 | + $result = array(); |
|
| 220 | + $priceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
| 221 | + |
|
| 222 | + foreach( $listItems as $id => $listItem ) |
|
| 223 | + { |
|
| 224 | + try |
|
| 225 | + { |
|
| 226 | + $refId = $listItem->getRefId(); |
|
| 227 | + $config = $listItem->getConfig(); |
|
| 228 | + |
|
| 229 | + if( isset( $products[$refId] ) ) |
|
| 230 | + { |
|
| 231 | + $prices = $products[$refId]->getRefItems( 'price', 'default', 'default' ); |
|
| 232 | + $currencyId = ( isset( $config['currency'] ) ? $config['currency'] : null ); |
|
| 233 | + |
|
| 234 | + $price = $priceManager->getLowestPrice( $prices, 1, $currencyId ); |
|
| 235 | + |
|
| 236 | + if( isset( $config['stock'] ) && $config['stock'] == 1 || |
|
| 237 | + isset( $config['price'] ) && $config['price'] == 1 && |
|
| 238 | + isset( $config['pricevalue'] ) && $config['pricevalue'] > $price->getValue() |
|
| 239 | + ) { |
|
| 240 | + $result[$id]['item'] = $products[$refId]; |
|
| 241 | + $result[$id]['price'] = $price; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + catch( \Exception $e ) { ; } // no price available |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + return $result; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Returns the products for the given IDs which are in stock in the warehouse |
|
| 254 | + * |
|
| 255 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 256 | + * @param array $prodIds List of product IDs |
|
| 257 | + * @param string $whId Unique warehouse ID |
|
| 258 | + */ |
|
| 259 | + protected function getProducts( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds, $whId ) |
|
| 260 | + { |
|
| 261 | + $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 262 | + $search = $productManager->createSearch( true ); |
|
| 263 | + $domains = array( 'text', 'price', 'media' ); |
|
| 264 | + |
|
| 265 | + $stockExpr = array( |
|
| 266 | + $search->compare( '==', 'product.stock.stocklevel', null ), |
|
| 267 | + $search->compare( '>', 'product.stock.stocklevel', 0 ), |
|
| 268 | + ); |
|
| 269 | + |
|
| 270 | + $expr = array( |
|
| 271 | + $search->compare( '==', 'product.id', $prodIds ), |
|
| 272 | + $search->getConditions(), |
|
| 273 | + $search->compare( '==', 'product.stock.warehouseid', $whId ), |
|
| 274 | + $search->combine( '||', $stockExpr ), |
|
| 275 | + ); |
|
| 276 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 277 | + $search->setSlice( 0, 0x7fffffff ); |
|
| 278 | + |
|
| 279 | + return $productManager->searchItems( $search, $domains ); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Returns the customer list type item for the given type code. |
|
| 285 | + * |
|
| 286 | + * @param string $code Unique code of the list type item |
|
| 287 | + * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
|
| 288 | + * @throws \Aimeos\Controller\Jobs\Exception If the list type item wasn't found |
|
| 289 | + */ |
|
| 290 | + protected function getListTypeItem( $code ) |
|
| 291 | + { |
|
| 292 | + $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists/type' ); |
|
| 293 | + |
|
| 294 | + $search = $manager->createSearch( true ); |
|
| 295 | + $search->setConditions( $search->compare( '==', 'customer.lists.type.code', $code ) ); |
|
| 296 | + $result = $manager->searchItems( $search ); |
|
| 297 | + |
|
| 298 | + if( ( $item = reset( $result ) ) === false ) { |
|
| 299 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'List type for domain "%1$s" and code "%2$s" not found', 'customer', $code ) ); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + return $item; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Returns the warehouse item for the given code. |
|
| 308 | + * |
|
| 309 | + * @param string $code Unique code of the warehouse item |
|
| 310 | + * @return \Aimeos\MShop\Product\Item\Stock\Warehouse\Iface Warehouse item |
|
| 311 | + * @throws \Aimeos\Controller\Jobs\Exception If the warehouse item wasn't found |
|
| 312 | + */ |
|
| 313 | + protected function getWarehouseItem( $code ) |
|
| 314 | + { |
|
| 315 | + if( !isset( $this->warehouses ) ) |
|
| 316 | + { |
|
| 317 | + $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock/warehouse' ); |
|
| 318 | + $search = $manager->createSearch( true ); |
|
| 319 | + |
|
| 320 | + $this->warehouses = array(); |
|
| 321 | + foreach( $manager->searchItems( $search ) as $whItem ) { |
|
| 322 | + $this->warehouses[ $whItem->getCode() ] = $whItem; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + if( !isset( $this->warehouses[$code] ) ) { |
|
| 327 | + throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No warehouse "%1$s" found', $code ) ); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + return $this->warehouses[$code]; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Sends the notification e-mail for the given customer address and products |
|
| 336 | + * |
|
| 337 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
|
| 338 | + * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address of the customer |
|
| 339 | + * @param array $products List of products a notification should be sent for |
|
| 340 | + */ |
|
| 341 | + protected function sendMail( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 342 | + \Aimeos\MShop\Common\Item\Address\Iface $address, array $products ) |
|
| 343 | + { |
|
| 344 | + $view = $context->getView(); |
|
| 345 | + $view->extProducts = $products; |
|
| 346 | + $view->extAddressItem = $address; |
|
| 347 | + |
|
| 348 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 349 | + $view->addHelper( 'translate', $helper ); |
|
| 350 | + |
|
| 351 | + $mailer = $context->getMail(); |
|
| 352 | + $message = $mailer->createMessage(); |
|
| 353 | + |
|
| 354 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 355 | + $view->addHelper( 'mail', $helper ); |
|
| 356 | + |
|
| 357 | + $client = $this->getClient( $context ); |
|
| 358 | + $client->setView( $view ); |
|
| 359 | + $client->getHeader(); |
|
| 360 | + $client->getBody(); |
|
| 361 | + |
|
| 362 | + $mailer->send( $message ); |
|
| 363 | + } |
|
| 364 | 364 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function getName() |
| 35 | 35 | { |
| 36 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product notification e-mails' ); |
|
| 36 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product notification e-mails'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function getDescription() |
| 46 | 46 | { |
| 47 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for watched products' ); |
|
| 47 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends e-mails for watched products'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -57,48 +57,48 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $langIds = array(); |
| 59 | 59 | $context = $this->getContext(); |
| 60 | - $typeId = $this->getListTypeItem( 'watch' )->getId(); |
|
| 60 | + $typeId = $this->getListTypeItem('watch')->getId(); |
|
| 61 | 61 | |
| 62 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 63 | - $custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 62 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
| 63 | + $custManager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 64 | 64 | |
| 65 | - $localeItems = $localeManager->searchItems( $localeManager->createSearch() ); |
|
| 65 | + $localeItems = $localeManager->searchItems($localeManager->createSearch()); |
|
| 66 | 66 | |
| 67 | - foreach( $localeItems as $localeItem ) |
|
| 67 | + foreach ($localeItems as $localeItem) |
|
| 68 | 68 | { |
| 69 | 69 | $langId = $localeItem->getLanguageId(); |
| 70 | 70 | |
| 71 | - if( isset( $langIds[$langId] ) ) { |
|
| 71 | + if (isset($langIds[$langId])) { |
|
| 72 | 72 | continue; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $langIds[$langId] = true; |
| 76 | 76 | // fetch language specific text and media items for products |
| 77 | - $context->getLocale()->setLanguageId( $langId ); |
|
| 77 | + $context->getLocale()->setLanguageId($langId); |
|
| 78 | 78 | |
| 79 | - $search = $custManager->createSearch( true ); |
|
| 79 | + $search = $custManager->createSearch(true); |
|
| 80 | 80 | $expr = array( |
| 81 | - $search->compare( '==', 'customer.languageid', $langId ), |
|
| 82 | - $search->compare( '==', 'customer.lists.typeid', $typeId ), |
|
| 83 | - $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 81 | + $search->compare('==', 'customer.languageid', $langId), |
|
| 82 | + $search->compare('==', 'customer.lists.typeid', $typeId), |
|
| 83 | + $search->compare('==', 'customer.lists.domain', 'product'), |
|
| 84 | 84 | $search->getConditions(), |
| 85 | 85 | ); |
| 86 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 87 | - $search->setSortations( array( $search->sort( '+', 'customer.id' ) ) ); |
|
| 86 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 87 | + $search->setSortations(array($search->sort('+', 'customer.id'))); |
|
| 88 | 88 | |
| 89 | 89 | $start = 0; |
| 90 | 90 | |
| 91 | 91 | do |
| 92 | 92 | { |
| 93 | - $customers = $custManager->searchItems( $search ); |
|
| 93 | + $customers = $custManager->searchItems($search); |
|
| 94 | 94 | |
| 95 | - $this->execute( $context, $customers, $typeId ); |
|
| 95 | + $this->execute($context, $customers, $typeId); |
|
| 96 | 96 | |
| 97 | - $count = count( $customers ); |
|
| 97 | + $count = count($customers); |
|
| 98 | 98 | $start += $count; |
| 99 | - $search->setSlice( $start ); |
|
| 99 | + $search->setSlice($start); |
|
| 100 | 100 | } |
| 101 | - while( $count >= $search->getSliceSize() ); |
|
| 101 | + while ($count >= $search->getSliceSize()); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -110,32 +110,32 @@ discard block |
||
| 110 | 110 | * @param array $customers List of customer items implementing \Aimeos\MShop\Customer\Item\Iface |
| 111 | 111 | * @param string $listTypeId Customer list type ID |
| 112 | 112 | */ |
| 113 | - protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers, $listTypeId ) |
|
| 113 | + protected function execute(\Aimeos\MShop\Context\Item\Iface $context, array $customers, $listTypeId) |
|
| 114 | 114 | { |
| 115 | 115 | $prodIds = $custIds = array(); |
| 116 | - $whItem = $this->getWarehouseItem( 'default' ); |
|
| 117 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 118 | - $listItems = $this->getListItems( $context, array_keys( $customers ), $listTypeId ); |
|
| 116 | + $whItem = $this->getWarehouseItem('default'); |
|
| 117 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 118 | + $listItems = $this->getListItems($context, array_keys($customers), $listTypeId); |
|
| 119 | 119 | |
| 120 | - foreach( $listItems as $id => $listItem ) |
|
| 120 | + foreach ($listItems as $id => $listItem) |
|
| 121 | 121 | { |
| 122 | 122 | $refId = $listItem->getRefId(); |
| 123 | - $custIds[ $listItem->getParentId() ][$id] = $refId; |
|
| 123 | + $custIds[$listItem->getParentId()][$id] = $refId; |
|
| 124 | 124 | $prodIds[$refId] = $refId; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $date = date( 'Y-m-d H:i:s' ); |
|
| 128 | - $products = $this->getProducts( $context, $prodIds, $whItem->getId() ); |
|
| 127 | + $date = date('Y-m-d H:i:s'); |
|
| 128 | + $products = $this->getProducts($context, $prodIds, $whItem->getId()); |
|
| 129 | 129 | |
| 130 | - foreach( $custIds as $custId => $list ) |
|
| 130 | + foreach ($custIds as $custId => $list) |
|
| 131 | 131 | { |
| 132 | 132 | $custListItems = $listIds = array(); |
| 133 | 133 | |
| 134 | - foreach( $list as $listId => $prodId ) |
|
| 134 | + foreach ($list as $listId => $prodId) |
|
| 135 | 135 | { |
| 136 | 136 | $listItem = $listItems[$listId]; |
| 137 | 137 | |
| 138 | - if( $listItem->getDateEnd() < $date ) { |
|
| 138 | + if ($listItem->getDateEnd() < $date) { |
|
| 139 | 139 | $listIds[] = $listId; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,22 +144,22 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | try |
| 146 | 146 | { |
| 147 | - $custProducts = $this->getListProducts( $custListItems, $products ); |
|
| 147 | + $custProducts = $this->getListProducts($custListItems, $products); |
|
| 148 | 148 | |
| 149 | - if( !empty( $custProducts ) ) |
|
| 149 | + if (!empty($custProducts)) |
|
| 150 | 150 | { |
| 151 | - $this->sendMail( $context, $customers[$custId]->getPaymentAddress(), $custProducts ); |
|
| 152 | - $listIds += array_keys( $custProducts ); |
|
| 151 | + $this->sendMail($context, $customers[$custId]->getPaymentAddress(), $custProducts); |
|
| 152 | + $listIds += array_keys($custProducts); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - catch( \Exception $e ) |
|
| 155 | + catch (\Exception $e) |
|
| 156 | 156 | { |
| 157 | 157 | $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; |
| 158 | - $msg = sprintf( $str, $custId, $e->getMessage() ); |
|
| 159 | - $context->getLogger()->log( $msg ); |
|
| 158 | + $msg = sprintf($str, $custId, $e->getMessage()); |
|
| 159 | + $context->getLogger()->log($msg); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $listManager->deleteItems( $listIds ); |
|
| 162 | + $listManager->deleteItems($listIds); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
| 171 | 171 | * @return \Aimeos\Client\Html\Iface Product notification e-mail client |
| 172 | 172 | */ |
| 173 | - protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 173 | + protected function getClient(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 174 | 174 | { |
| 175 | - if( !isset( $this->client ) ) |
|
| 175 | + if (!isset($this->client)) |
|
| 176 | 176 | { |
| 177 | - $templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' ); |
|
| 178 | - $this->client = \Aimeos\Client\Html\Email\Watch\Factory::createClient( $context, $templatePaths ); |
|
| 177 | + $templatePaths = $this->getAimeos()->getCustomPaths('client/html'); |
|
| 178 | + $this->client = \Aimeos\Client\Html\Email\Watch\Factory::createClient($context, $templatePaths); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return $this->client; |
@@ -190,20 +190,20 @@ discard block |
||
| 190 | 190 | * @param string $listTypeId Customer list type ID |
| 191 | 191 | * @return array List of customer list items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 192 | 192 | */ |
| 193 | - protected function getListItems( \Aimeos\MShop\Context\Item\Iface $context, array $custIds, $listTypeId ) |
|
| 193 | + protected function getListItems(\Aimeos\MShop\Context\Item\Iface $context, array $custIds, $listTypeId) |
|
| 194 | 194 | { |
| 195 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
| 195 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
| 196 | 196 | |
| 197 | 197 | $search = $listManager->createSearch(); |
| 198 | 198 | $expr = array( |
| 199 | - $search->compare( '==', 'customer.lists.parentid', $custIds ), |
|
| 200 | - $search->compare( '==', 'customer.lists.typeid', $listTypeId ), |
|
| 201 | - $search->compare( '==', 'customer.lists.domain', 'product' ), |
|
| 199 | + $search->compare('==', 'customer.lists.parentid', $custIds), |
|
| 200 | + $search->compare('==', 'customer.lists.typeid', $listTypeId), |
|
| 201 | + $search->compare('==', 'customer.lists.domain', 'product'), |
|
| 202 | 202 | ); |
| 203 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 204 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 203 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 204 | + $search->setSlice(0, 0x7fffffff); |
|
| 205 | 205 | |
| 206 | - return $listManager->searchItems( $search ); |
|
| 206 | + return $listManager->searchItems($search); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
@@ -214,35 +214,35 @@ discard block |
||
| 214 | 214 | * @param array $products List of product items implementing \Aimeos\MShop\Product\Item\Iface |
| 215 | 215 | * @return array Multi-dimensional associative list of list IDs as key and product / price item maps as values |
| 216 | 216 | */ |
| 217 | - protected function getListProducts( array $listItems, array $products ) |
|
| 217 | + protected function getListProducts(array $listItems, array $products) |
|
| 218 | 218 | { |
| 219 | 219 | $result = array(); |
| 220 | - $priceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
| 220 | + $priceManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price'); |
|
| 221 | 221 | |
| 222 | - foreach( $listItems as $id => $listItem ) |
|
| 222 | + foreach ($listItems as $id => $listItem) |
|
| 223 | 223 | { |
| 224 | 224 | try |
| 225 | 225 | { |
| 226 | 226 | $refId = $listItem->getRefId(); |
| 227 | 227 | $config = $listItem->getConfig(); |
| 228 | 228 | |
| 229 | - if( isset( $products[$refId] ) ) |
|
| 229 | + if (isset($products[$refId])) |
|
| 230 | 230 | { |
| 231 | - $prices = $products[$refId]->getRefItems( 'price', 'default', 'default' ); |
|
| 232 | - $currencyId = ( isset( $config['currency'] ) ? $config['currency'] : null ); |
|
| 231 | + $prices = $products[$refId]->getRefItems('price', 'default', 'default'); |
|
| 232 | + $currencyId = (isset($config['currency']) ? $config['currency'] : null); |
|
| 233 | 233 | |
| 234 | - $price = $priceManager->getLowestPrice( $prices, 1, $currencyId ); |
|
| 234 | + $price = $priceManager->getLowestPrice($prices, 1, $currencyId); |
|
| 235 | 235 | |
| 236 | - if( isset( $config['stock'] ) && $config['stock'] == 1 || |
|
| 237 | - isset( $config['price'] ) && $config['price'] == 1 && |
|
| 238 | - isset( $config['pricevalue'] ) && $config['pricevalue'] > $price->getValue() |
|
| 236 | + if (isset($config['stock']) && $config['stock'] == 1 || |
|
| 237 | + isset($config['price']) && $config['price'] == 1 && |
|
| 238 | + isset($config['pricevalue']) && $config['pricevalue'] > $price->getValue() |
|
| 239 | 239 | ) { |
| 240 | 240 | $result[$id]['item'] = $products[$refId]; |
| 241 | 241 | $result[$id]['price'] = $price; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | - catch( \Exception $e ) { ; } // no price available |
|
| 245 | + catch (\Exception $e) {; } // no price available |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | return $result; |
@@ -256,27 +256,27 @@ discard block |
||
| 256 | 256 | * @param array $prodIds List of product IDs |
| 257 | 257 | * @param string $whId Unique warehouse ID |
| 258 | 258 | */ |
| 259 | - protected function getProducts( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds, $whId ) |
|
| 259 | + protected function getProducts(\Aimeos\MShop\Context\Item\Iface $context, array $prodIds, $whId) |
|
| 260 | 260 | { |
| 261 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
| 262 | - $search = $productManager->createSearch( true ); |
|
| 263 | - $domains = array( 'text', 'price', 'media' ); |
|
| 261 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
| 262 | + $search = $productManager->createSearch(true); |
|
| 263 | + $domains = array('text', 'price', 'media'); |
|
| 264 | 264 | |
| 265 | 265 | $stockExpr = array( |
| 266 | - $search->compare( '==', 'product.stock.stocklevel', null ), |
|
| 267 | - $search->compare( '>', 'product.stock.stocklevel', 0 ), |
|
| 266 | + $search->compare('==', 'product.stock.stocklevel', null), |
|
| 267 | + $search->compare('>', 'product.stock.stocklevel', 0), |
|
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | $expr = array( |
| 271 | - $search->compare( '==', 'product.id', $prodIds ), |
|
| 271 | + $search->compare('==', 'product.id', $prodIds), |
|
| 272 | 272 | $search->getConditions(), |
| 273 | - $search->compare( '==', 'product.stock.warehouseid', $whId ), |
|
| 274 | - $search->combine( '||', $stockExpr ), |
|
| 273 | + $search->compare('==', 'product.stock.warehouseid', $whId), |
|
| 274 | + $search->combine('||', $stockExpr), |
|
| 275 | 275 | ); |
| 276 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 277 | - $search->setSlice( 0, 0x7fffffff ); |
|
| 276 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 277 | + $search->setSlice(0, 0x7fffffff); |
|
| 278 | 278 | |
| 279 | - return $productManager->searchItems( $search, $domains ); |
|
| 279 | + return $productManager->searchItems($search, $domains); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
@@ -287,16 +287,16 @@ discard block |
||
| 287 | 287 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
| 288 | 288 | * @throws \Aimeos\Controller\Jobs\Exception If the list type item wasn't found |
| 289 | 289 | */ |
| 290 | - protected function getListTypeItem( $code ) |
|
| 290 | + protected function getListTypeItem($code) |
|
| 291 | 291 | { |
| 292 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists/type' ); |
|
| 292 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists/type'); |
|
| 293 | 293 | |
| 294 | - $search = $manager->createSearch( true ); |
|
| 295 | - $search->setConditions( $search->compare( '==', 'customer.lists.type.code', $code ) ); |
|
| 296 | - $result = $manager->searchItems( $search ); |
|
| 294 | + $search = $manager->createSearch(true); |
|
| 295 | + $search->setConditions($search->compare('==', 'customer.lists.type.code', $code)); |
|
| 296 | + $result = $manager->searchItems($search); |
|
| 297 | 297 | |
| 298 | - if( ( $item = reset( $result ) ) === false ) { |
|
| 299 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'List type for domain "%1$s" and code "%2$s" not found', 'customer', $code ) ); |
|
| 298 | + if (($item = reset($result)) === false) { |
|
| 299 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('List type for domain "%1$s" and code "%2$s" not found', 'customer', $code)); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return $item; |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | * @return \Aimeos\MShop\Product\Item\Stock\Warehouse\Iface Warehouse item |
| 311 | 311 | * @throws \Aimeos\Controller\Jobs\Exception If the warehouse item wasn't found |
| 312 | 312 | */ |
| 313 | - protected function getWarehouseItem( $code ) |
|
| 313 | + protected function getWarehouseItem($code) |
|
| 314 | 314 | { |
| 315 | - if( !isset( $this->warehouses ) ) |
|
| 315 | + if (!isset($this->warehouses)) |
|
| 316 | 316 | { |
| 317 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock/warehouse' ); |
|
| 318 | - $search = $manager->createSearch( true ); |
|
| 317 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock/warehouse'); |
|
| 318 | + $search = $manager->createSearch(true); |
|
| 319 | 319 | |
| 320 | 320 | $this->warehouses = array(); |
| 321 | - foreach( $manager->searchItems( $search ) as $whItem ) { |
|
| 322 | - $this->warehouses[ $whItem->getCode() ] = $whItem; |
|
| 321 | + foreach ($manager->searchItems($search) as $whItem) { |
|
| 322 | + $this->warehouses[$whItem->getCode()] = $whItem; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if( !isset( $this->warehouses[$code] ) ) { |
|
| 327 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No warehouse "%1$s" found', $code ) ); |
|
| 326 | + if (!isset($this->warehouses[$code])) { |
|
| 327 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No warehouse "%1$s" found', $code)); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | return $this->warehouses[$code]; |
@@ -338,27 +338,27 @@ discard block |
||
| 338 | 338 | * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address of the customer |
| 339 | 339 | * @param array $products List of products a notification should be sent for |
| 340 | 340 | */ |
| 341 | - protected function sendMail( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 342 | - \Aimeos\MShop\Common\Item\Address\Iface $address, array $products ) |
|
| 341 | + protected function sendMail(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 342 | + \Aimeos\MShop\Common\Item\Address\Iface $address, array $products) |
|
| 343 | 343 | { |
| 344 | 344 | $view = $context->getView(); |
| 345 | 345 | $view->extProducts = $products; |
| 346 | 346 | $view->extAddressItem = $address; |
| 347 | 347 | |
| 348 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) ); |
|
| 349 | - $view->addHelper( 'translate', $helper ); |
|
| 348 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId())); |
|
| 349 | + $view->addHelper('translate', $helper); |
|
| 350 | 350 | |
| 351 | 351 | $mailer = $context->getMail(); |
| 352 | 352 | $message = $mailer->createMessage(); |
| 353 | 353 | |
| 354 | - $helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message ); |
|
| 355 | - $view->addHelper( 'mail', $helper ); |
|
| 354 | + $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); |
|
| 355 | + $view->addHelper('mail', $helper); |
|
| 356 | 356 | |
| 357 | - $client = $this->getClient( $context ); |
|
| 358 | - $client->setView( $view ); |
|
| 357 | + $client = $this->getClient($context); |
|
| 358 | + $client->setView($view); |
|
| 359 | 359 | $client->getHeader(); |
| 360 | 360 | $client->getBody(); |
| 361 | 361 | |
| 362 | - $mailer->send( $message ); |
|
| 362 | + $mailer->send($message); |
|
| 363 | 363 | } |
| 364 | 364 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | $this->sendMail( $context, $customers[$custId]->getPaymentAddress(), $custProducts ); |
| 152 | 152 | $listIds += array_keys( $custProducts ); |
| 153 | 153 | } |
| 154 | - } |
|
| 155 | - catch( \Exception $e ) |
|
| 154 | + } catch( \Exception $e ) |
|
| 156 | 155 | { |
| 157 | 156 | $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; |
| 158 | 157 | $msg = sprintf( $str, $custId, $e->getMessage() ); |
@@ -241,8 +240,7 @@ discard block |
||
| 241 | 240 | $result[$id]['price'] = $price; |
| 242 | 241 | } |
| 243 | 242 | } |
| 244 | - } |
|
| 245 | - catch( \Exception $e ) { ; } // no price available |
|
| 243 | + } catch( \Exception $e ) { ; } // no price available |
|
| 246 | 244 | } |
| 247 | 245 | |
| 248 | 246 | return $result; |