Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Commit

Permalink
Changed code for PSR-4 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Oct 7, 2015
1 parent bd028ee commit 72ef4a0
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 119 deletions.
29 changes: 16 additions & 13 deletions lib/custom/src/MW/Config/Zend2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
*/


namespace Aimeos\MW\Config;


/**
* Configuration setting class using ZF2 Config
*
* @package MW
* @subpackage Config
*/
class MW_Config_Zend2
extends MW_Config_Abstract
implements MW_Config_Interface
class Zend2
extends \Aimeos\MW\Config\Base
implements \Aimeos\MW\Config\Iface
{
private $config;
private $paths;
Expand All @@ -25,10 +28,10 @@ class MW_Config_Zend2
/**
* Initialize config object with ZF2 Config instance
*
* @param Zend\Config\Config $config Configuration object
* @param \Zend\Config\Config $config Configuration object
* @param array|string $path Filesystem path or list of paths to the configuration files
*/
public function __construct( Zend\Config\Config $config, $path = array() )
public function __construct( \Zend\Config\Config $config, $path = array() )
{
$this->config = $config;
$this->paths = (array) $path;
Expand Down Expand Up @@ -88,10 +91,10 @@ public function set( $path, $value )
{
$val = $config->get( $parts[$i] );

if( $val instanceof Zend\Config\Config ) {
if( $val instanceof \Zend\Config\Config ) {
$config = $val;
} else {
$config = $config->{$parts[$i]} = new Zend\Config\Config( array(), true );
$config = $config->{$parts[$i]} = new \Zend\Config\Config( array(), true );
}
}

Expand All @@ -106,11 +109,11 @@ public function set( $path, $value )
* @param array $parts List of config name parts to look for
* @return mixed Found value or null if no value is available
*/
protected function getPart( Zend\Config\Config $config, array $parts )
protected function getPart( \Zend\Config\Config $config, array $parts )
{
if( ( $key = array_shift( $parts ) ) !== null && isset( $config->$key ) )
{
if( $config->$key instanceof Zend\Config\Config )
if( $config->$key instanceof \Zend\Config\Config )
{
if( count( $parts ) > 0 ) {
return $this->getPart( $config->$key, $parts );
Expand All @@ -133,7 +136,7 @@ protected function getPart( Zend\Config\Config $config, array $parts )
* @param string $path Path to the configuration directory
* @param array $parts List of config name parts to look for
*/
protected function load( Zend\Config\Config $config, $path, array $parts )
protected function load( \Zend\Config\Config $config, $path, array $parts )
{
if( ( $key = array_shift( $parts ) ) !== null )
{
Expand All @@ -142,7 +145,7 @@ protected function load( Zend\Config\Config $config, $path, array $parts )
if( is_dir( $newPath ) )
{
if( !isset( $config->$key ) ) {
$config->$key = new Zend\Config\Config( array(), true );
$config->$key = new \Zend\Config\Config( array(), true );
}

$this->load( $config->$key, $newPath, $parts );
Expand All @@ -151,10 +154,10 @@ protected function load( Zend\Config\Config $config, $path, array $parts )
if( file_exists( $newPath . '.php' ) )
{
if( !isset( $config->$key ) ) {
$config->$key = new Zend\Config\Config( array(), true );
$config->$key = new \Zend\Config\Config( array(), true );
}

$config->$key->merge( new Zend\Config\Config( $this->includeFile( $newPath . '.php' ), true ) );
$config->$key->merge( new \Zend\Config\Config( $this->includeFile( $newPath . '.php' ), true ) );
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions lib/custom/src/MW/Logger/Zend2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
*/


namespace Aimeos\MW\Logger;


/**
* Log messages using Zend\Log.
*
* @package MW
* @subpackage Logger
*/
class MW_Logger_Zend2 extends MW_Logger_Abstract implements MW_Logger_Interface
class Zend2 extends \Aimeos\MW\Logger\Base implements \Aimeos\MW\Logger\Iface
{
private $logger = null;


/**
* Initializes the logger object.
*
* @param Zend\Log\Logger $logger Zend logger object
* @param \Zend\Log\Logger $logger Zend logger object
*/
public function __construct( Zend\Log\Logger $logger )
public function __construct( \Zend\Log\Logger $logger )
{
$this->logger = $logger;
}
Expand All @@ -36,10 +39,10 @@ public function __construct( Zend\Log\Logger $logger )
* @param string $message Message text that should be written to the log facility
* @param integer $priority Priority of the message for filtering
* @param string $facility Facility for logging different types of messages (e.g. message, auth, user, changelog)
* @throws MW_Logger_Exception If an error occurs in Zend_Log
* @see MW_Logger_Abstract for available log level constants
* @throws \Aimeos\MW\Logger\Exception If an error occurs in Zend_Log
* @see \Aimeos\MW\Logger\Base for available log level constants
*/
public function log( $message, $priority = MW_Logger_Abstract::ERR, $facility = 'message' )
public function log( $message, $priority = \Aimeos\MW\Logger\Base::ERR, $facility = 'message' )
{
try
{
Expand All @@ -49,11 +52,11 @@ public function log( $message, $priority = MW_Logger_Abstract::ERR, $facility =

$this->logger->log( $priority, '<' . $facility . '> ' . $message );
}
catch( Zend\Log\Exception\InvalidArgumentException $ze ) {
throw new MW_Logger_Exception( $ze->getMessage() );
catch( \Zend\Log\Exception\InvalidArgumentException $ze ) {
throw new \Aimeos\MW\Logger\Exception( $ze->getMessage() );
}
catch( Zend\Log\Exception\RuntimeException $ze ) {
throw new MW_Logger_Exception( $ze->getMessage() );
catch( \Zend\Log\Exception\RuntimeException $ze ) {
throw new \Aimeos\MW\Logger\Exception( $ze->getMessage() );
}
}
}
67 changes: 35 additions & 32 deletions lib/custom/src/MW/Mail/Message/Zend2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
*/


namespace Aimeos\MW\Mail\Message;


/**
* Zend implementation for creating e-mails.
*
* @package MW
* @subpackage Mail
*/
class MW_Mail_Message_Zend2 implements MW_Mail_Message_Interface
class Zend2 implements \Aimeos\MW\Mail\Message\Iface
{
private $html;
private $text;
Expand All @@ -27,9 +30,9 @@ class MW_Mail_Message_Zend2 implements MW_Mail_Message_Interface
/**
* Initializes the message instance.
*
* @param Zend\Mail\Message $object Zend mail object
* @param \Zend\Mail\Message $object Zend mail object
*/
public function __construct( Zend\Mail\Message $object, $charset = 'UTF-8' )
public function __construct( \Zend\Mail\Message $object, $charset = 'UTF-8' )
{
$this->object = $object;
}
Expand All @@ -40,7 +43,7 @@ public function __construct( Zend\Mail\Message $object, $charset = 'UTF-8' )
*
* @param string $email Source e-mail address
* @param string|null $name Name of the user sending the e-mail or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addFrom( $email, $name = null )
{
Expand All @@ -54,7 +57,7 @@ public function addFrom( $email, $name = null )
*
* @param string $email Destination address of the target mailbox
* @param string|null $name Name of the user owning the target mailbox or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addTo( $email, $name = null )
{
Expand All @@ -68,7 +71,7 @@ public function addTo( $email, $name = null )
*
* @param string $email Destination address for a copy
* @param string|null $name Name of the user owning the target mailbox or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addCc( $email, $name = null )
{
Expand All @@ -82,7 +85,7 @@ public function addCc( $email, $name = null )
*
* @param string $email Destination address for a hidden copy
* @param string|null $name Name of the user owning the target mailbox or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addBcc( $email, $name = null )
{
Expand All @@ -96,7 +99,7 @@ public function addBcc( $email, $name = null )
*
* @param string $email E-mail address which should receive all replies
* @param string|null $name Name of the user which should receive all replies or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addReplyTo( $email, $name = null )
{
Expand All @@ -110,7 +113,7 @@ public function addReplyTo( $email, $name = null )
*
* @param string $name Name of the custom e-mail header
* @param string $value Text content of the custom e-mail header
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addHeader( $name, $value )
{
Expand All @@ -124,7 +127,7 @@ public function addHeader( $name, $value )
*
* @param string $email Source e-mail address
* @param string|null $name Name of the user who sent the message or null for no name
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function setSender( $email, $name = null )
{
Expand All @@ -137,7 +140,7 @@ public function setSender( $email, $name = null )
* Sets the subject of the message.
*
* @param string $subject Subject of the message
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function setSubject( $subject )
{
Expand All @@ -150,15 +153,15 @@ public function setSubject( $subject )
* Sets the text body of the message.
*
* @param string $message Text body of the message
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function setBody( $message )
{
$part = new Zend\Mime\Part( $message );
$part = new \Zend\Mime\Part( $message );

$part->charset = $this->charset;
$part->encoding = Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$part->type = Zend\Mime\Mime::TYPE_TEXT;
$part->encoding = \Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$part->type = \Zend\Mime\Mime::TYPE_TEXT;

$this->text = $part;
return $this;
Expand All @@ -169,16 +172,16 @@ public function setBody( $message )
* Sets the HTML body of the message.
*
* @param string $message HTML body of the message
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function setBodyHtml( $message )
{
$part = new Zend\Mime\Part( $message );
$part = new \Zend\Mime\Part( $message );

$part->charset = $this->charset;
$part->encoding = Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$part->disposition = Zend\Mime\Mime::DISPOSITION_INLINE;
$part->type = Zend\Mime\Mime::TYPE_HTML;
$part->encoding = \Zend\Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$part->disposition = \Zend\Mime\Mime::DISPOSITION_INLINE;
$part->type = \Zend\Mime\Mime::TYPE_HTML;

$this->html = $part;
return $this;
Expand All @@ -192,13 +195,13 @@ public function setBodyHtml( $message )
* @param string $mimetype Mime type of the attachment (e.g. "text/plain", "application/octet-stream", etc.)
* @param string|null $filename Name of the attached file (or null if inline disposition is used)
* @param string $disposition Type of the disposition ("attachment" or "inline")
* @return MW_Mail_Message_Interface Message object
* @return \Aimeos\MW\Mail\Message\Iface Message object
*/
public function addAttachment( $data, $mimetype, $filename, $disposition = 'attachment' )
{
$part = new Zend\Mime\Part( $data );
$part = new \Zend\Mime\Part( $data );

$part->encoding = Zend\Mime\Mime::ENCODING_BASE64;
$part->encoding = \Zend\Mime\Mime::ENCODING_BASE64;
$part->disposition = $disposition;
$part->filename = $filename;
$part->type = $mimetype;
Expand Down Expand Up @@ -226,10 +229,10 @@ public function embedAttachment( $data, $mimetype, $filename )
$newfile = ++$cnt . '_' . $filename;
}

$part = new Zend\Mime\Part( $data );
$part = new \Zend\Mime\Part( $data );

$part->disposition = Zend\Mime\Mime::DISPOSITION_INLINE;
$part->encoding = Zend\Mime\Mime::ENCODING_BASE64;
$part->disposition = \Zend\Mime\Mime::DISPOSITION_INLINE;
$part->encoding = \Zend\Mime\Mime::ENCODING_BASE64;
$part->filename = $newfile;
$part->type = $mimetype;
$part->id = md5( $newfile . mt_rand() );
Expand All @@ -251,7 +254,7 @@ public function getObject()

if( !empty( $this->embedded ) )
{
$type = Zend\Mime\Mime::MULTIPART_RELATED;
$type = \Zend\Mime\Mime::MULTIPART_RELATED;

if( $this->html != null ) {
$parts[] = $this->createContainer( array_merge( array( $this->html ), $this->embedded ), $type );
Expand All @@ -270,15 +273,15 @@ public function getObject()

if( count( $parts ) === 2 )
{
$type = Zend\Mime\Mime::MULTIPART_ALTERNATIVE;
$type = \Zend\Mime\Mime::MULTIPART_ALTERNATIVE;
$msgparts = array( $this->createContainer( array_reverse( $parts ), $type ) );
}
else if( !empty( $parts ) )
{
$msgparts = $parts;
}

$msg = new Zend\Mime\Message();
$msg = new \Zend\Mime\Message();
$msg->setParts( array_merge( $msgparts, $this->attach ) );

$this->object->setBody( $msg );
Expand All @@ -305,12 +308,12 @@ public function __clone()
*/
protected function createContainer( array $parts, $type )
{
$msg = new Zend\Mime\Message();
$msg = new \Zend\Mime\Message();
$msg->setParts( $parts );

$part = new Zend\Mime\Part( $msg->generateMessage() );
$part = new \Zend\Mime\Part( $msg->generateMessage() );

$part->encoding = Zend\Mime\Mime::ENCODING_8BIT;
$part->encoding = \Zend\Mime\Mime::ENCODING_8BIT;
$part->boundary = $msg->getMime()->boundary();
$part->disposition = null;
$part->charset = null;
Expand Down

0 comments on commit 72ef4a0

Please sign in to comment.