<?php
/**
 * This file is part of the MimeMailer package.
 *
 * Copyright (c) 2013-2016 Pierre Cassat <me@e-piwi.fr> and contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The source code of this package is available online at
 * <http://github.com/atelierspierrot/mime-mailer>.
 */

namespace MimeMailer;

use \Library\Converter\Html2Text;

/**
 * @TODO Cite all RFCs for each header field
 *
 * @author  piwi <me@e-piwi.fr>
 */
class MimeMessage
    extends AbstractMailerAware
    implements MessageInterface
{

    /**
     * @var array
     */
    protected $from;

    /**
     * @var array
     */
    protected $to;

    /**
     * @var array
     */
    protected $cc;

    /**
     * @var array
     */
    protected $bcc;

    /**
     * @var string
     */
    protected $attachment;

    /**
     * @var string
     */
    protected $subject;

    /**
     * @var string
     */
    protected $text;

    /**
     * @var string
     */
    protected $html;

    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $message;

    /**
     * @var array Set of clearing values
     */
    public static $clearings = array(
        'from'=>'',
        'to'=>array(),
        'cc'=>array(),
        'bcc'=>array(),
        'attachment'=>array(),
        'header'=>'',
        'subject'=>'',
        'text'=>'',
        'html'=>'',
        'id'=>null
    );

// --------------------
// Construction
// --------------------

    /**
     * Construction of a MimeEmail object
     *
     * @param string $from_name
     * @param string $from_mail
     * @param string|array $to
     * @param string $subject
     * @param string $message
     */
    public function __construct($from_name = '', $from_mail = null, $to = null, $subject = null, $message = null)
    {
        $this->_init();
        if (!is_null($from_mail)) {
            $this->setFrom($from_mail, $from_name);
        }
        if (!is_null($to)) {
            $this->setTo($to);
        }
        if (!is_null($subject)) {
            $this->setSubject($subject);
        }
        if (!is_null($message)) {
            $this->setText($message);
        }
    }

    /**
     * First initialization of the object
     *
     * @return void
     */
    protected function _init()
    {
        foreach (self::$clearings as $var=>$val) {
            $this->{$var} = $val;
        }
        if (is_null($this->id)) {
            $this->id = uniqid(time());
        }
    }

    /**
     * Initialization before sending messages
     *
     * @return void
     */
    protected function _buildInit()
    {
        $this->clear('message');

        $this->getMailer()
            ->setRegistry('boundary', $this->makeBoundary())
            ->setRegistry('boundary_ctt', $this->makeBoundary());

        // message type
        if (strlen($this->text)>0 && count($this->attachment)>0) {
            $this->getMailer()->setRegistry('message_type', 'multipart/mixed');
        } elseif (strlen($this->text)>0 && strlen($this->html)>0 && count($this->attachment)==0) {
            $this->getMailer()
                ->setRegistry('message_type', 'multipart/alternative')
                ->setRegistry('boundary_ctt', $this->getMailer()->getRegistry('boundary'));
        } else {
            $this->getMailer()->setRegistry('message_type', 'text/plain');
        }
    }

// --------------------
// Getters/Setters/Clearers
// --------------------

    /**
     * Global setter
     *
     * @param string $name
     * @param mixed $val
     * @return self
     */
    public function set($name, $val)
    {
        if (property_exists($this, $name)) {
            $this->{$name} = $val;
        }
        return $this;
    }

    /**
     * Global getter
     *
     * @param string $name
     * @return mixed
     */
    public function get($name)
    {
        return property_exists($this, $name) ? $this->{$name} : null;
    }

    /**
     * Global variable clearer
     *
     * @param string $name
     * @return self
     */
    public function clear($name = null)
    {
        if (!is_null($name)) {
            $name = strtolower($name);
            if (array_key_exists($name, self::$clearings)) {
                $this->{$name} = self::$clearings[$self::$clearings];
            }
        } else {
            foreach (self::$clearings as $n=>$v) {
                $this->{$n} = $v;
            }
        }
        return $this;
    }

    /**
     * Get a fromated address info (name <email>) for `$name` field
     *
     * @param string $name
     * @return string
     */
    public function getFormated($name)
    {
        $field_value = $this->get($name);
        return is_array($field_value) ? Helper::mailListTagger($field_value) : $field_value;
    }

    /**
     * Get message ID
     *
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set From field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @param bool $reply Set the "reply-to" to the same address ? (default is TRUE)
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setFrom($mail = '', $name = null, $reply = true)
    {
        $mail = trim($mail);
        if (strlen($mail) && Helper::isEmail($mail)) {
            $this->from = !empty($name) ? array($name=>$mail) : array($mail);
            $this->getMailer()->setRegistry('Return-Path', '<'.$mail.'>', 'headers');
            $this->getMailer()->setRegistry('X-Sender', $mail, 'headers');
            if ($reply) {
                $this->setReplyTo($mail, $name);
            }
        }
        return $this;
    }

    /**
     * Set To field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setTo($mail = '', $name = null)
    {
        $this->to = Helper::deduplicate(
            array_merge($this->to, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set Cc field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setCc($mail = '', $name = null)
    {
        $this->cc = Helper::deduplicate(
            array_merge($this->cc, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set Bcc field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setBcc($mail = '', $name = null)
    {
        $this->bcc = Helper::deduplicate(
            array_merge($this->bcc, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set mail file attachment
     *
     * @param string|array $file The file or files to attach
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setAttachment($file = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        if (is_array($file)) {
            foreach ($file as $_f) {
                if (file_exists($_f)) {
                    $this->attachment[] = $_f;
                }
            }
        } else {
            if (file_exists($file)) {
                $this->attachment[] = $file;
            }
        }
        return $this;
    }

    /**
     * Set mail object
     *
     * @param string $subject The subject content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setSubject($subject = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('subject');
        }
        $this->subject = $subject;
        return $this;
    }

    /**
     * Set plain text version
     *
     * If $text='auto', the text version will be generated from the HTML content
     *
     * @param string $text The plain text content or keyword 'auto' to auto-generate it from the HTML content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setText($text = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        if ('auto'==$text) {
            if (!empty($this->html)) {
                $html_content = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $this->html);
                $this->text .= Helper::formatText(Helper::html2text($html_content));
            }
        } else {
            $this->text .= Helper::formatText($text);
        }
        return $this;
    }

    /**
     * Set HTML version
     *
     * @param string $html The HTML content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setHtml($html = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        $this->html .= Helper::formatText($html, 'ascii');
        return $this;
    }

    /**
     * Set Reply-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setReplyTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Reply-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Foolowup-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setFollowupTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Followup-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Errors-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setErrorsTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Errors-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Disposition-Notification-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setDispositionNotificationTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Disposition-Notification-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Abuse-Reports-To header field
     *
     * @param string/array $mail
     * @param string/bool $name
     * @return self
     */
    public function setAbuseReportsTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()
                ->setRegistry('Abuse-Reports-To', $_m, 'headers')
                ;
        }
        return $this;
    }

    /**
     * Set Return-Receipt-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setReturnReceiptTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Return-Receipt-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Get sent built message
     *
     * @return string
     */
    public function getMessage()
    {
        return $this->message;
    }

// --------------------
// Sending
// --------------------

    /**
     * Message builder
     *
     * @return self
     */
    public function buildMessage()
    {
        $this->_buildInit();

        // From header
        if (is_array($this->from) && count($this->from)>0) {
            $from = null;
            while (is_null($from)==true) {
                foreach ($this->from as $n=>$m) {
                    $from = array($n=>$m);
                }
            }
            $this->from = $from;
        }
        if (count($this->from)==0) {
            $this->getMailer()->addError('No sender setted!');
        } else {
            $this->message .= Helper::listAddresses($this->from, 'from');
        }

        // To header
        if (count($this->to)>0) {
            $this->message .= Helper::listAddresses($this->to, 'to');
        }

        // CC header
        if (count($this->cc)>0) {
            $this->message .= Helper::listAddresses($this->cc, 'cc');
        }

        // BCC header
        if (count($this->bcc)>0) {
            $this->message .= Helper::listAddresses($this->bcc, 'bcc');
        }

        // Headers
        foreach ($this->getMailer()->getRegistry('headers') as $entry=>$v_entry) {
            if (isset($v_entry)) {
                $this->message .= Helper::headerTagger($entry, $v_entry).Mailer::$LINE_ENDING;
            }
        }
        $bound = 0;

        // Mail type
        $type = $this->getMailer()->getRegistry('message_type');
        if (!is_null($type) && $type!='text/plain') {
            $bound = 1;
            $this->message .= Helper::headerTagger("Content-Type", $type,
                array('boundary'=>$this->getMailer()->getRegistry('boundary'))).Mailer::$LINE_ENDING;
            $this->message .= "This is a multi-part message in MIME format.".Mailer::$LINE_ENDING;
            if ($type == 'multipart/mixed') {
                $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Type", "multipart/alternative",
                    array('boundary'=>$this->getMailer()->getRegistry('boundary_ctt'))).Mailer::$LINE_ENDING;
            }
        }

        // Text content
        if (strlen($this->text)/* && !strlen($this->html)*/) {
            if ($bound) {
                $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary_ctt').Mailer::$LINE_ENDING;
                //ne prend pas les css en compte
//                $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit").Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Type", "text/plain",
                    array('charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
            }
            $this->message .= Mailer::$LINE_ENDING.$this->text;
        }

        // HTML content
        if (strlen($this->html)) {
            if ($bound) {
                $this->message .= Mailer::$LINE_ENDING.Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER
                    .$this->getMailer()->getRegistry('boundary_ctt').Mailer::$LINE_ENDING;
            }
            // prend les css en compte
//            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit").Mailer::$LINE_ENDING;
//            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "quoted-printable").Mailer::$LINE_ENDING;
            $this->message .= Helper::headerTagger("Content-Type", "text/html",
                array('charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
            $this->message .= Mailer::$LINE_ENDING.trim($this->html, Mailer::$LINE_ENDING);
        }
        if ($bound) {
            $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER
                .$this->getMailer()->getRegistry('boundary_ctt').Mailer::BOUNDARY_CLOSER.Mailer::$LINE_ENDING;
        }

        // Attachments
        /* @todo what is max ? */
        $max = 10;
        if (count($this->attachment)>0) {
            for ($i=0;$i<$max;$i++) {
                if (isset($this->attachment[$i])) {
                    $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
                    $filename = basename($this->attachment[$i]);
                    $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Type", Helper::getMimeType($filename),
                        array('name'=>$filename, 'charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "base64").Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Disposition", 'attachment',
                        array('filename'=>$filename)).Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Description", $filename).Mailer::$LINE_ENDING;
                    $this->message .= Mailer::$LINE_ENDING.chunk_split(base64_encode($file));
                    $file = $filename = "";
                }
            }
            $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::BOUNDARY_CLOSER.Mailer::$LINE_ENDING;
        }

        return $this;
    }

    /**
     * Build a boundary value
     *
     * @return string The generated boundary
     */
    public function makeBoundary()
    {
        return Mailer::BOUNDARY_PREFIX.md5(uniqid(time())).'.'.$this->id;
    }

    /**
     * Make a basic substitution in the object body
     *
     * @param string $search The string to search
     * @param string $replace The string to use for replacement
     * @return string The generated body
     */
    public function substitution($search, $replace)
    {
        $this->body = str_replace($search, $replace, $this->body);
        return $this->body;
    }
}

// Endfile


<?php

/**
 * MvcCore
 *
 * This source file is subject to the BSD 3 License
 * For the full copyright and license information, please view
 * the LICENSE.md file that are distributed with this source code.
 *
 * @copyright	Copyright (c) 2016 Tom Flídr (https://github.com/mvccore/mvccore)
 * @license		https://mvccore.github.io/docs/mvccore/4.0.0/LICENCE.md
 */

namespace MvcCore\Ext\Routers\ModuleLocalization;

trait RewriteRoutingChecks
{
	/**
	 * Return `TRUE` if there is possible (or not) by additional info array
	 * records to route incoming request by given route as first argument.
	 * Check, if route object has defined any http method and if the request has
	 * the same method or not, check if route has defined any allowed module and
	 * if routed module name is presented in allowed module names array and
	 * check if route object is localized route instance and if there is also
	 * any localization found in request. If there is a conflict, return
	 * `FALSE`, if there is everything OK, return `TRUE`.
	 * @param \MvcCore\IRoute $route
	 * @param array $additionalInfo
	 *				Array with request method as string, localization found in
	 *				request as bool, route is localized as bool and boolean
	 *				about not skip localized routes matching when request has no
	 *				localization in path and other conditions described inside
	 *				this function.
	 * @return bool
	 */
	protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) {
		list ($requestMethod, $localizationInRequest, $routeIsLocalized, $localizationRoutesSkipping) = $additionalInfo;

		$routeMethod = $route->GetMethod();
		if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE;

		$modules = $route->GetAdvancedConfigProperty(\MvcCore\Ext\Routers\Modules\IRoute::CONFIG_ALLOWED_MODULES);
		if (is_array($modules) && !in_array($this->currentModule, $modules)) return TRUE;

		// skip localized routes matching when request has no localization in path
		if ($routeIsLocalized && $localizationInRequest === FALSE) {
			// but do not skip localized routes matching when request has no localization in path and:
			// - when method is post and router has not allowed to process other methods than GET
			// - or when method is anything and router has allowed to process other methods than GET
			if ($localizationRoutesSkipping) return TRUE;
		}

		if ($routeIsLocalized === FALSE && isset($this->allowNonLocalizedRoutes) && $this->allowNonLocalizedRoutes === FALSE)
			return TRUE;

		return FALSE;
	}
}


<?php

/**
 * @package Google Analytics Charts
 * @author Iurii Makukh <gplcart.software@gmail.com>
 * @copyright Copyright (c) 2018, Iurii Makukh <gplcart.software@gmail.com>
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0
 */

namespace gplcart\modules\ga_chart;

/**
 * Main class for Google Analytics Charts module
 */
class Main
{
    /**
     * Implements "template.render"
     * @param array $templates
     * @param array $data
     * @param string| null $rendered
     * @param \gplcart\core\Controller $controller
     */
    public function hookTemplateRender($templates, $data, $rendered, $controller)
    {
        $template = reset($templates);

        if (strpos($template, '/modules/ga_report/templates/panels/') !== false
            && isset($data['content']['data']['report']['data'])
            && isset($data['content']['data']['handler']['id'])) {

            $handler_id = $data['content']['data']['handler']['id'];
            $controller->setJsSettings("ga_chart_$handler_id", $data['content']['data']['report']['data']);

            $controller->setJs(__DIR__ . "/js/handlers/$handler_id.js");
            $controller->setJs(__DIR__ . "/js/common.js");
        }
    }
}


<?php
namespace BlogBundle\DataFixtures\ORM;

use CoreBundle\DataFixtures\SqlScriptFixture;
use BlogBundle\Entity\Category;
use BlogBundle\Entity\Post;
use BlogBundle\Entity\PostTranslation;
use BlogBundle\Entity\Tag;
use BlogBundle\Entity\Image;

/*
 * php app/console doctrine:fixtures:load --fixtures=vendor/sebardo/core/BlogBundle/DataFixtures/ORM/LoadBlogData.php
 */
class LoadBlogData extends SqlScriptFixture
{
    /**
     * There two kind of fixtures
     * Bundle fixtures: all info bundle needed
     * Dev fixtures: info for testing porpouse
     */
    public function createFixtures()
    {
        /**
         * Bundle fixtures
         */
        if($this->container->getParameter('core.fixtures_bundle_blog')){
            $this->runSqlScript('Translation.sql');
        }

        /**
         * Dev fixtures
         */
        if($this->container->getParameter('core.fixtures_dev_blog')){

            $actor = $this->getManager()->getRepository('CoreBundle:BaseActor')->findOneByUsername('user');
            $locales = $this->get('core_manager')->getLocales();

            $publishDate = new \DateTime('now');
            $publishDate->modify('+ 1 month');

            $categories = array(
                'Signs', 'Elements', 'Planets', 'Cusps', 'Compatibility',
            );
            $tags = array(
                'Aries', 'Fire', 'Mars', 'Taurus', 'Earth', 'Moon', 'Gemini', 'Air', 'Mercury', 'Cancer'
            );

            $titles = array(
                'es' => 'Aries Signo Solar',
                'en' => 'Aries Sun Sign',
                'de' => 'Widder Sun Sign'
            );
            $titles2 = array(
                'es' => 'Something in mars',
                'en' => 'Something in mars',
                'de' => 'Something in mars'
            );
            $titles3 = array(
                'es' => 'The other side',
                'en' => 'The other side',
                'de' => 'The other side'
            );
            $titles4 = array(
                'es' => 'Mars attack',
                'en' => 'Mars attack',
                'de' => 'Mars attack'
            );
            $shortDesciptions = array(
                'es' => '
Aries es el primer signo del zodiaco, y eso es más o menos como Los nacidos bajo este signo verse a sí mismos: en primer lugar. Aries son los líderes de la manada, primero en la fila para que las cosas funcionen. Sea o no todo se hace es otra cuestión, ya que en Aries prefiere iniciar en lugar de en completarse. ¿Tiene un proyecto que necesitan una a poner en marcha? Llame a Aries, por todos los medios. El liderazgo mostrada por Aries es más impresionante, por lo que no se sorprenda si pueden reunir a las tropas contra probabilidades aparentemente insuperables.
',
                'en' => "
Aries is the first sign of the zodiac, and that's pretty much how those born under this sign see themselves: first. Aries are the leaders of the pack, first in line to get things going. Whether or not everything gets done is another question altogether, for an Aries prefers to initiate rather than to complete. Do you have a project needing a kick-start? Call an Aries, by all means. The leadership displayed by Aries is most impressive, so don't be surprised if they can rally the troops against seemingly insurmountable odds.
",
                'de' => '
Widder ist das erste Zeichen des Tierkreises , und das ist ziemlich viel, wie diese unter diesem Zeichen geboren sie selbst sehen: zuerst. Widder sind die Führer der Packung, in erster Linie in Sachen in Gang zu bringen. Ob oder ob nicht alles wird getan ist eine ganz andere Frage, für ein Widder zu initiieren, anstatt abzuschließen vorzieht. Haben Sie ein Projekt benötigen einen Kick-Start? Rufen Sie einen Widder, mit allen Mitteln. Die Führung von Aries angezeigt ist sehr beeindruckend, so seien Sie nicht überrascht, wenn Sie die Truppen gegen scheinbar unüberwindliche Schwierigkeiten sammeln können.
'
            );
            $desciptions = array(
                'es' => "
El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. No es probable que convencer al Ram para ablandar; gente de tesis son contundente y al grano. Junto con esas cualidades viene la pura fuerza de la naturaleza de Aries, una fuerza puede no lograr hecho un buen negocio. Gran parte de la unidad de Aries para competir y para ganar se debe a su calidad cardenal. Cardinales signos de amor para que funcione, y Aries ejemplifica esto incluso mejor que el Cáncer, Libra o Capricornio.El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. No es probable que convencer al Ram para ablandar; gente de tesis son contundente y al grano. Junto con esas cualidades viene la pura fuerza de la naturaleza de Aries, una fuerza puede no lograr hecho un buen negocio. Gran parte de la unidad de Aries para competir y para ganar se debe a su calidad cardenal. Cardinales signos de amor para que funcione, y Aries ejemplifica esto incluso mejor que el Cáncer, Libra o Capricornio.El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez.

El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. No es probable que convencer al Ram para ablandar; gente de tesis son contundente y al grano. Junto con esas cualidades viene la pura fuerza de la naturaleza de Aries, una fuerza puede no lograr hecho un buen negocio. Gran parte de la unidad de Aries para competir y para ganar se debe a su calidad cardenal. Cardinales signos de amor para que funcione, y Aries ejemplifica esto incluso mejor que el Cáncer, Libra o Capricornio.El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. No es probable que convencer al Ram para ablandar; gente de tesis son contundente y al grano. Junto con esas cualidades viene la pura fuerza de la naturaleza de Aries, una fuerza puede no lograr hecho un buen negocio. Gran parte de la unidad de Aries para competir y para ganar se debe a su calidad cardenal. Cardinales signos de amor para que funcione, y Aries ejemplifica esto incluso mejor que el Cáncer, Libra o Capricornio.El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez.

El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez. No es probable que convencer al Ram para ablandar; gente de tesis son contundente y al grano. Junto con esas cualidades viene la pura fuerza de la naturaleza de Aries, una fuerza puede no lograr hecho un buen negocio. Gran parte de la unidad de Aries para competir y para ganar se debe a su calidad cardenal. Cardinales signos de amor para que funcione, y Aries ejemplifica esto incluso mejor que el Cáncer, Libra o Capricornio.El símbolo de Aries es el carnero, y que a la vez Buenas y malas noticias. Impulsivo Aries podría verse tentado a embestir Sus ideas hasta en la sopa de todo el mundo, sin siquiera molestarse en preguntar si quieren saber. Es en momentos de tesis cuando termine tal vez desee símbolo de Aries era una criatura más tenue, más cordero que la RAM Tal vez.
",
                'en' => "
The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.

The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.

The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.

The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps. You're not likely to convince the Ram to soften up; these folks are blunt and to the point. Along with those qualities comes the sheer force of the Aries nature, a force that can actually accomplish a great deal. Much of Aries' drive to compete and to win comes from its Cardinal Quality. Cardinal Signs love to get things going, and Aries exemplifies this even better than Cancer, Libra or Capricorn.The symbol of Aries is the Ram, and that's both good and bad news. Impulsive Aries might be tempted to ram their ideas down everyone's throats without even bothering to ask if they want to know. It's these times when you may wish Aries' symbol were a more subdued creature, more lamb than ram perhaps.
",
                'de' => "
Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.

Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.

Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen. Du bist wahrscheinlich nicht die Ram davon zu überzeugen, zu erweichen; Diese Leute sind stumpf und auf den Punkt. Zusammen mit diesen Eigenschaften kommt die schiere Kraft der Widder Natur, eine Kraft whos Das kann sehr viel erreichen. Vieles von dem Auto Widder zu konkurrieren und zu gewinnen, kommt von seiner Cardinal Qualität. Kardinal Signs lieben es, Dinge in Gang zu bringen, und Widder exemplifiziert esta sogar besser als Krebs, Waage oder Steinbock.Das Symbol des Widders ist der Ram, und das ist gut und schlechte Nachrichten Beides. Impulsive Widder könnten ihre Gedanken auf jeden Kehlen, ohne auch nur die Mühe zu fragen, ob Sie wissen, Sie möchten zu rammen versucht sein. Es sind diese Zeiten, wenn Sie Widder wünschen Mai Symbol 'waren ein gedämpfter Kreatur, mehr als Lamm Vielleicht rammen.
"
            );

            //Create Categories
            foreach ($categories as $categoryName) {
                $category[$categoryName] = new Category();
                $category[$categoryName]->setName($categoryName);
                $category[$categoryName]->setDescription('Description category '.$categoryName);
                $category[$categoryName]->setMetaTitle('Meta titlte category '.$categoryName);
                $category[$categoryName]->setMetaDescription('Meta description category '.$categoryName);
                $this->getManager()->persist($category[$categoryName]);
            }
            //Create Tags
            foreach ($tags as $tagName) {
                $tag[$tagName] = new Tag();
                $tag[$tagName]->setName($tagName);
                $tag[$tagName]->setDescription('Description tag '.$tagName);
                $tag[$tagName]->setMetaTitle('Meta titlte tag '.$tagName);
                $tag[$tagName]->setMetaDescription('Meta description tag '.$tagName);
                $this->getManager()->persist($tag[$tagName]);
            }
            //Create Post
            $post = new Post();
            $postTrans = array();
            foreach ($locales as $locale) {
                $postTrans[$locale] = new PostTranslation();
                $postTrans[$locale]->setLocale($locale);
                $postTrans[$locale]->setTitle($titles[$locale]);
                $postTrans[$locale]->setShortDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setDescription($desciptions[$locale]);
                $postTrans[$locale]->setMetaTitle($titles[$locale]);
                $postTrans[$locale]->setMetaDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setTranslatable($post);
                $post->addTranslation($postTrans[$locale]);
                $this->getManager()->persist($postTrans[$locale]);
            }
            $post->addCategory($category['Signs']);
            $post->addTag($tag['Aries']);
            $post->addTag($tag['Fire']);
            $post->setActor($actor);
            $post->setHighlighted(true);
            $post->setPublished($publishDate);
            $this->getManager()->persist($post);

            $post2 = new Post();
            foreach ($locales as $locale) {
                $postTrans[$locale] = new PostTranslation();
                $postTrans[$locale]->setLocale($locale);
                $postTrans[$locale]->setTitle($titles2[$locale]);
                $postTrans[$locale]->setShortDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setDescription($desciptions[$locale]);
                $postTrans[$locale]->setMetaTitle($titles2[$locale]);
                $postTrans[$locale]->setMetaDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setTranslatable($post);
                $post2->addTranslation($postTrans[$locale]);
                $this->getManager()->persist($postTrans[$locale]);
            }
            $post2->addCategory($category['Signs']);
            $post2->addCategory($category['Compatibility']);
            $post2->addTag($tag['Earth']);
            $post2->addTag($tag['Fire']);
            $post2->addTag($tag['Moon']);
            $post2->setActor($actor);
            $post2->setHighlighted(true);
            $post2->setPublished($publishDate);
            $this->getManager()->persist($post2);

            $post3 = new Post();
            foreach ($locales as $locale) {
                $postTrans[$locale] = new PostTranslation();
                $postTrans[$locale]->setLocale($locale);
                $postTrans[$locale]->setTitle($titles3[$locale]);
                $postTrans[$locale]->setShortDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setDescription($desciptions[$locale]);
                $postTrans[$locale]->setMetaTitle($titles3[$locale]);
                $postTrans[$locale]->setMetaDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setTranslatable($post);
                $post3->addTranslation($postTrans[$locale]);
                $this->getManager()->persist($postTrans[$locale]);
            }
            $post3->addCategory($category['Signs']);
            $post3->addCategory($category['Planets']);
            $post3->addTag($tag['Earth']);
            $post3->addTag($tag['Fire']);
            $post3->addTag($tag['Moon']);
            $post3->setActor($actor);
            $post3->setHighlighted(true);
            $post3->setPublished($publishDate);
            $this->getManager()->persist($post3);

            $post4 = new Post();
            foreach ($locales as $locale) {
                $postTrans[$locale] = new PostTranslation();
                $postTrans[$locale]->setLocale($locale);
                $postTrans[$locale]->setTitle($titles4[$locale]);
                $postTrans[$locale]->setShortDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setDescription($desciptions[$locale]);
                $postTrans[$locale]->setMetaTitle($titles4[$locale]);
                $postTrans[$locale]->setMetaDescription($shortDesciptions[$locale]);
                $postTrans[$locale]->setTranslatable($post);
                $post4->addTranslation($postTrans[$locale]);
                $this->getManager()->persist($postTrans[$locale]);
            }
            $post4->addCategory($category['Signs']);
            $post4->addCategory($category['Planets']);
            $post4->addTag($tag['Earth']);
            $post4->addTag($tag['Fire']);
            $post4->addTag($tag['Moon']);
            $post4->setActor($actor);
            $post4->setHighlighted(true);
            $post4->setPublished($publishDate);

            @mkdir(__DIR__ . '/../../../../../../web/uploads/images/post/4');
            @mkdir(__DIR__ . '/../../../../../../web/uploads/images/post/4/thumbnail');
            copy(__DIR__ . '/images/4/mars-attack-df5e0630b435be5870ed71881f706df2.jpeg', __DIR__ . '/../../../../../../web/uploads/images/post/4/mars-attack-df5e0630b435be5870ed71881f706df2.jpeg');
            copy(__DIR__ . '/images/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_142.jpg', __DIR__ . '/../../../../../../web/uploads/images/post/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_142.jpg');
            copy(__DIR__ . '/images/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_260.jpg', __DIR__ . '/../../../../../../web/uploads/images/post/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_260.jpg');
            copy(__DIR__ . '/images/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_380.jpg', __DIR__ . '/../../../../../../web/uploads/images/post/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_380.jpg');
            copy(__DIR__ . '/images/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_400.jpg', __DIR__ . '/../../../../../../web/uploads/images/post/4/thumbnail/mars-attack-df5e0630b435be5870ed71881f706df2_400.jpg');
            $image = new Image();
            $image->setPath('mars-attack-df5e0630b435be5870ed71881f706df2.jpeg');
            $this->getManager()->persist($image);

            $post4->addImage($image);
            $this->getManager()->persist($post4);

            $this->getManager()->getFilters()->disable('oneLocale');
            $this->getManager()->flush();

        }
    }

    public function getOrder()
    {
        return 2; // the order in which fixtures will be loaded
    }
}


<?php

declare(strict_types=1);

namespace Chubbyphp\Translation;

final class LocaleTranslationProvider implements LocaleTranslationProviderInterface
{
    /**
     * @var string
     */
    private $locale;

    /**
     * @var string[]|array
     */
    private $translations;

    /**
     * @param array|string[] $translations
     */
    public function __construct(string $locale, array $translations)
    {
        $this->locale = $locale;
        $this->translations = $translations;
    }

    /**
     * @return string
     */
    public function getLocale(): string
    {
        return $this->locale;
    }

    /**
     * @param string $key
     * @param array  $arguments
     *
     * @return string|null
     */
    public function translate(string $key, array $arguments = [])
    {
        if (!isset($this->translations[$key])) {
            return null;
        }

        if (!$this->hasNamedArguments($arguments)) {
            return $this->translateWithoutNamedArguments($key, $arguments);
        }

        return $this->translateWithNamedArguments($key, $arguments);
    }

    /**
     * @param array $arguments
     *
     * @return bool
     */
    private function hasNamedArguments(array $arguments): bool
    {
        foreach (array_keys($arguments) as $name) {
            if (!is_numeric($name)) {
                return true;
            }
        }

        return false;
    }

    /**
     * @param string $key
     * @param array  $arguments
     *
     * @return string
     */
    private function translateWithoutNamedArguments(string $key, array $arguments = []): string
    {
        return sprintf($this->translations[$key], ...$arguments);
    }

    /**
     * @param string $key
     * @param array  $arguments
     *
     * @return string
     */
    private function translateWithNamedArguments(string $key, array $arguments = []): string
    {
        $translation = $this->translations[$key];
        foreach ($arguments as $name => $value) {
            $translation = str_replace('{{'.$name.'}}', $value, $translation);
        }

        return $translation;
    }
}


<?php namespace ForeverPHP\Core;

use ForeverPHP\Core\Exceptions\SetupException;

/**
 * Importa objetos y configuraciones del framework y Apps.
 *
 * @author      Daniel Nuñez S. <dnunez@emarva.com>
 * @since       Version 1.0.0
 */
class Setup {
    /**
     * Inicializador, se encarga de cargar los requerimientos para la
     * ejecución.
     *
     * @return void
     */
    public static function initialize() {
        /*
         * Defino la ruta de los templates y estaticos del framework.
         */
        static::toDefine('FOREVERPHP_ROOT', dirname(dirname(__FILE__)));
        static::toDefine('FOREVERPHP_TEMPLATES_PATH', FOREVERPHP_ROOT . DS . 'Static' . DS . 'templates' . DS);
        static::toDefine('FOREVERPHP_STATIC_PATH', basename(FOREVERPHP_ROOT) . DS . 'Static' . DS);

        /*
         * Establece como el manejador de errores ExceptionManager.
         */
        set_error_handler('\ForeverPHP\Core\ExceptionManager::errorHandler');

        /*
         * Establece como el manejador de excepciones no controladas a
         * ExceptionManager.
         */
        set_exception_handler('\ForeverPHP\Core\ExceptionManager::exceptionHandler');

        /*
         * Le deja el control de la función de cierre a ExceptionManager.
         */
        register_shutdown_function('\ForeverPHP\Core\ExceptionManager::shutdown');
    }

    /**
     * Carga una libreria al nucleo del framework.
     *
     * @param string $name
     */
    public static function importLib($name) {
        $libPath = FOREVERPHP_ROOT . DS . 'libs' . DS . $name . '.php';

        if (file_exists($libPath)) {
            include_once $libPath;
        } else {
            throw new SetupException("La librería ($name) no existe.");
        }
    }

    /**
     * Carga un objeto de foreverPHP.
     *
     * @param string $name
     */
    public static function import($name) {
        $importPath = FOREVERPHP_ROOT . DS . $name . '.php';

        if (file_exists($importPath)) {
            include_once $importPath;
        } else {
            throw new SetupException("The object to import ($name) not exists.");
        }
    }

    /**
     * Carga un objeto desde las Apps.
     *
     * @param string $path
     */
    public static function importFromApp($path) {
        $importPath = APPS_ROOT . DS . $path . '.php';

        if (file_exists($importPath)) {
            include_once $importPath;
        } else {
            throw new SetupException("The object to import ($path) not exists.");
        }
    }

    /**
     * Permite definir valores, comprobando si ya existen
     * previamente.
     *
     * @param string $define
     * @param string $value
     */
    public static function toDefine($define, $value) {
        if (!defined($define)) {
            define($define, $value);
        }
    }
}


<?php
namespace Poirot\Queue\Payload;

use Poirot\Queue\Interfaces\iPayload;
use Poirot\Queue\Interfaces\iPayloadQueued;

class QueuedPayload
    extends BasePayload
    implements iPayloadQueued
{
    protected $uid;
    /** @var iPayload|BasePayload */
    protected $payload;
    protected $queue;
    protected $timeCreated;

    /**
     * Constructor.
     *
     * @param iPayload $payload
     */
    function __construct(iPayload $payload)
    {
        $this->payload = $payload;
    }

    /**
     * Get Storage UID for This Payload
     *
     * @return mixed
     */
    function getUID()
    {
        return $this->uid;
    }

    /**
     * Get Payload Queued
     *
     * @return iPayload
     */
    function getPayload()
    {
        return $this->payload;
    }

    /**
     * With Given Payload
     *
     * @param iPayload $payload
     *
     * @return $this
     */
    function withPayload(iPayload $payload)
    {
        $n = clone $this;
        $n->payload = $payload;
        return $n;
    }

    /**
     * Get Payload Content
     *
     * @return mixed Serializable content
     */
    function getData()
    {
        return $this->payload->getData();
    }

    /**
     * With Given Payload
     *
     * @param mixed $data Serializable payload
     *
     * @return $this
     */
    function withData($data)
    {
        $n = clone $this;
        $p = clone $this->payload;
        $p = $p->withData($data);
        $n->payload = $p;
        return $n;
    }

    /**
     * Get Queue Name
     *
     * @return string Queue name
     */
    function getQueue()
    {
        return $this->queue;
    }

    /**
     * Queue Name
     *
     * @param string $queue
     *
     * @return $this
     */
    function withQueue($queue)
    {
        $n = clone $this;
        $n->queue = $queue;
        return $n;
    }

    /**
     * With UID
     *
     * @param mixed $uid
     *
     * @return $this
     */
    function withUID($uid)
    {
        $n = clone $this;
        $n->uid = $uid;
        return $n;
    }

    /**
     * Get Created Timestamp
     *
     * @return int Timestamp
     */
    function getCreatedTimestamp()
    {
        if (! $this->timeCreated )
            $this->timeCreated = time();

        return $this->timeCreated;
    }

    // Implement Serializable:

    /**
     * @inheritdoc
     */
    function serialize()
    {
        $s = [
            'uid' => $this->getUID(),
            'qn'  => $this->getQueue(),
            'pl'  => serialize( $this->getPayload() ),
            'tm'  => $this->getCreatedTimestamp(),
        ];

        return serialize($s);
    }

    /**
     * @inheritdoc
     */
    function unserialize($serialized)
    {
        $us = unserialize($serialized);
        $this->uid         = $us['uid'];
        $this->queue       = $us['qn'];
        $this->payload     = unserialize($us['pl']);
        $this->timeCreated = $us['tm'];
    }
}


<?php namespace Versatile\Query;

use Versatile\Query\Contracts\SyntaxParser as Parser;
use Versatile\Query\SyntaxParser as DefaultParser;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder as Query;
use Versatile\Introspection\EloquentPathIntrospector;
use UnderflowException;
use App;

class Builder
{

    protected $parser;

    protected $introspector;

    protected $model;

    protected $query;

    protected $joinClasses = [];

    protected $joinTables = [];

    protected $joinAliases = [];

    protected $joinMethods = [];

    protected $relationNs = 'Illuminate\Database\Eloquent\Relations\\';

    protected $columns;

    protected $withs = [];

    protected $wheres = [];

    protected $whereIns = [];

    protected $orderBys = [];

    protected $onlyQueryColumns = [];

    /**
     * @var callable
     **/
    protected $queryModifier;

    public function __construct(Model $model){
        $this->model = $model;
        $this->query = $model->newQuery();
        $this->parser = new DefaultParser;
        $this->introspector = new EloquentPathIntrospector($this->parser);
    }

    public function with($relations)
    {

        if (is_string($relations)) {
            $relations = func_get_args();
        }

        $this->withs = array_merge($this->withs, $relations);
        return $this;
    }

    public function withColumn($column){

        $columns = is_array($column) ? $column : func_get_args();

        foreach ($columns as $column) {
            $this->columns[] = $column;
        }

        return $this;
    }

    public function withColumns($columns, $clear=false)
    {
        if ($clear) {
            $this->columns = [];
        }
        return $this->withColumn($columns);
    }

    public function where($column, $operator = null, $value = null, $boolean = 'and'){

        $this->wheres[] = [
            'column'    => $column,
            'operator'  => $operator,
            'value'     => $value,
            'boolean'   => $boolean
        ];

        return $this;

    }

    public function whereIn($column, $values = null, $boolean = 'and', $not=false){

        $this->whereIns[] = [
            'column'    => $column,
            'values'    => $values,
            'boolean'   => $boolean,
            'not'       => $not
        ];

        return $this;

    }

    /**
     * Add an "or where" clause to the query.
     *
     * @param  string  $column
     * @param  string  $operator
     * @param  mixed   $value
     * @return \Illuminate\Database\Eloquent\Builder|static
     */
    public function orWhere($column, $operator = null, $value = null)
    {
        return $this->where($column, $operator, $value, 'or');
    }

    /**
     * Add an "order by" clause to the query.
     *
     * @param  string  $column
     * @param  string  $direction
     * @return $this
     */
    public function orderBy($column, $direction = 'asc'){

        $this->orderBys[] = [
            'column'    => $column,
            'direction' => $direction
        ];

        return $this;

    }

    /**
     * Alias to set the "offset" value of the query.
     *
     * @param  int  $value
     * @return \Illuminate\Database\Query\Builder|static
     */
    public function skip($value){
        $this->buildQuery($this->getQueryColumns())->skip($value);
        return $this;
    }

    /**
     * Set the "limit" value of the query.
     *
     * @param  int  $value
     * @return $this
     */
    public function limit($value){
        $this->buildQuery($this->getQueryColumns())->limit($value);
        return $this;
    }

    /**
     * Alias to set the "limit" value of the query.
     *
     * @param  int  $value
     * @return \Illuminate\Database\Query\Builder|static
     */
    public function take($value){
        return $this->limit($value);
    }

    /**
     * {@inheritdoc}
     *
     * @param string $key The key name
     * @return bool
     **/
    public function isRelatedKey($key)
    {
        if (!$this->parser->isRelatedKey($key)) {
            return false;
        }

        list($join, $key) = $this->toJoinAndKey($key);

        return $this->model->getTable() != $join;

    }

    /**
     * Check if a key is a relation
     *
     * @param string $key
     * @return bool
     **/
    public function isRelation($key)
    {
        if(!method_exists($this->model, $key)) {
            return false;
        }
        $relation = $this->model->{$key}();
        return ($relation instanceof Relation);
    }

    /**
     * {@inheritdoc}
     *
     * @param string $path Der Name der Eigenschaft
     * @return array Sowas: array('join.join','id')
     **/
    public function toJoinAndKey($path)
    {
        return $this->parser->toJoinAndKey($path);
    }

    /**
     * {@inheritdoc}
     *
     * @param array $parts The segments
     * @return string The path
     **/
    public function buildPath(array $parts)
    {
        return $this->parser->buildPath($parts);
    }

    public function getParser()
    {
        return $this->parser;
    }

    public function setParser(Parser $parser)
    {
        $this->parser = $parser;
        return $this;
    }

    public function getRelation($model, $name){

        if ($this->parser->isRelatedKey($name)) {
            list($join, $key) = $this->parser->toJoinAndKey($name);
            $class = $this->introspector->classOfPath($model, $join);
            $model = new $class();
            $name = $key;
        }

        if (!method_exists($model, $name)) {
            throw new UnderflowException("Method $name does not exists on model " . get_class($this->model));
        }

        $relation = $model->{$name}();

        return $relation;

    }

    protected function addColumnsToQuery(Query $query, $columns)
    {

        $mainTable = $this->model->getTable();

        foreach ($this->mergedQueryColumns() as $column) {

            list($join, $column) = $this->toJoinAndKey($column);

            if ($join && $join != $mainTable) {
                $query->with($join);
                $this->addJoinOnce($query, $this->model, $join);
            }

            if ($this->isRelation($column)) {
                $query->with($column);
                $this->addJoinOnce($query, $this->model, $column);
            }

        }

        // Check again if columns where added by the joins
//         foreach
    }

    protected function addWithsToQuery(Query $query)
    {
        foreach ($this->withs as $relation) {
            $query->with($relation);
        }
    }

    protected function addWheresToQuery(Query $query)
    {

        $mainTable = $this->model->getTable();

        foreach ($this->wheres as $where) {

            $column     = $where['column'];
            $operator   = $where['operator'];
            $value      = $where['value'];
            $boolean    = $where['boolean'];

            if ($this->isRelatedKey($column)) {

                list($join, $property) = $this->toJoinAndKey($column);

                if($join){

                    $this->addJoinOnce($query, $this->model, $join);

                    $query->where($this->joinColumn($join, $property), $operator, $value, $boolean);

                }

            } else {
                $query->where("$mainTable.$column", $operator, $value, $boolean);

            }
        }
    }

    protected function addWhereInsToQuery(Query $query)
    {

        foreach ($this->whereIns as $where) {

            $column  = $where['column'];
            $values  = $where['values'];
            $boolean = $where['boolean'];
            $not     = $where['not'];

            if ($this->isRelatedKey($column)) {

                list($join, $property) = $this->toJoinAndKey($column);

                if ($join) {

                    $this->addJoinOnce($query, $this->model, $join);

                    $query->whereIn($this->joinColumn($join, $property), $values, $boolean, $not);

                }

            } else {
                $table = $this->model->getTable();
                $query->whereIn("$table.$column", $values, $boolean, $not);
            }
        }
    }

    protected function addOrderBysToQuery(Query $query)
    {

        foreach ($this->orderBys as $orderBy) {

            $column = $orderBy['column'];
            $direction = $orderBy['direction'];

            if ($this->isRelatedKey($column)) {

                list($join, $property) = $this->toJoinAndKey($column);

                if($join){

                    $this->addJoinOnce($query, $this->model, $join);

                    $query->orderBy($this->joinColumn($join, $property), $direction);

                }

            }
            else{
                $table = $this->model->getTable();
                $query->orderBy("$table.$column", $direction);

            }

        }

    }

    public function buildQuery(array $columns)
    {

        $this->joinClasses = [];
        $this->joinTable = [];
        $this->joinAliases = [];

        $query = clone $this->query;

        $this->addWithsToQuery($query);

        $this->addColumnsToQuery($query, $columns);

        $this->addWheresToQuery($query);

        $this->addWhereInsToQuery($query);

        $this->addOrderBysToQuery($query);

        if ($this->queryModifier) {
            call_user_func($this->queryModifier, $query);
        }

        return $query;

    }

    public function addJoinOnce(Query $query, $model, $name){

        if (!isset($this->joinClasses[$name])) {

            $relation = $this->getRelation($this->model, $name);

            $ns = $this->relationNs;
            $relationClass = get_class($relation);

            switch ($relationClass) {

                case "{$ns}BelongsTo":
                    $this->applyBelongsTo($query, $model, $relation, $name);
                    break;

                case "{$ns}HasOne":
                    $this->applyHasOne($query, $model, $relation, $name);
                    break;
                case "{$ns}BelongsToMany":
                    $this->applyBelongsToMany($query, $model, $relation, $name);
                    break;
                default:
                    throw new UnderflowException('Currently only BelongsTo and HasOne is supported');
            }

        }

    }

    /**
     * This allows to hook into the builded query. Due the query is builded
     * fresh every time this is the only way to manipulate it
     *
     * @param callable $modifier
     * @return self
     **/
    public function modifyQuery(callable $modifier)
    {
        $this->queryModifier = $modifier;
        return $this;
    }

    protected function applyBelongsTo(Query $query, Model $model, BelongsTo $belongsTo, $name){

        if(isset($this->joinClasses[$name])){
            return;
        }

        $modelTable = '';

        // If the table has already an alias
        if (str_contains($name, '.')) {
            $path = explode('.', $name);
            array_pop($path);
            $parentPath = implode('.', $path);
            if (isset($this->joinAliases[$parentPath])) {
                $modelTable = $this->joinAliases[$parentPath];
            }
        }

        if (!$modelTable) {
            $modelTable = $belongsTo->getParent()->getTable();
        }
        $related = $belongsTo->getRelated();
        $relatedTable = $related->getTable();
        $foreignKey = $belongsTo->getForeignKey();
        $otherKey = $belongsTo->getOwnerKey();

        $alias = $this->joinNameToAlias($name);

        $joinMethod = $this->getJoinMethod($name);

        $query->{$joinMethod}("$relatedTable AS $alias", "$modelTable.$foreignKey",'=',"$alias.$otherKey");
        $query->distinct();

        $this->addQueryColumn("$modelTable.$foreignKey");
        $this->joinClasses[$name] = $belongsTo->getRelated();
        $this->joinTable[$name] = $relatedTable;
        $this->joinAliases[$name] = $alias;

    }

    protected function applyHasOne(Query $query, Model $model, HasOne $hasOne, $name){

        if(isset($this->joinClasses[$name])){
            return;
        }

        $modelTable = $model->getTable();
        $related = $hasOne->getRelated();
        $relatedTable = $related->getTable();
        $foreignKey = $hasOne->getForeignKeyName();

        $qualifiedLocalKey = $hasOne->getQualifiedParentKeyName();
        list($parentTable, $localKey) = explode('.', $qualifiedLocalKey);

        if ($this->parser->isRelatedKey($name)) {
            list($parentPath, $key) = $this->parser->toJoinAndKey($name);
            $this->addJoinOnce($query, $this->model, $parentPath);
            $qualifiedLocalKey = $this->joinAliases[$parentPath] . ".$localKey";
        }
        else {
            $qualifiedLocalKey = $hasOne->getQualifiedParentKeyName();
        }

        $alias = $this->joinNameToAlias($name);

        $joinMethod = $this->getJoinMethod($name);

        $query->{$joinMethod}("$relatedTable AS $alias", "$qualifiedLocalKey",'=',"$alias.$foreignKey");
        $query->distinct();

        $this->joinClasses[$name] = $hasOne->getRelated();
        $this->joinTable[$name] = $relatedTable;
        $this->joinAliases[$name] = $alias;

    }

    protected function applyBelongsToMany(Query $query, Model $model, BelongsToMany $belongsToMany, $name){

        if(isset($this->joinClasses[$name])){
            return;
        }

        $modelTable = $model->getTable();
        $related = $belongsToMany->getRelated();
        $pivotTable = $belongsToMany->getTable();
        $pivotAlias = $pivotTable.'_pivot';
        $pivotLocalKey = $belongsToMany->getQualifiedRelatedKeyName();
        $relatedTable = $related->getTable();
        $relationKey = $related->getKeyName();
        $foreignKey = $belongsToMany->getForeignKey();
        $qualifiedLocalKey = $belongsToMany->getQualifiedParentKeyName();

        $alias = $this->joinNameToAlias($name);

        $joinMethod = $this->getJoinMethod($name);

        $query->{$joinMethod}("$pivotTable", "$qualifiedLocalKey",'=',"$foreignKey");
        $query->{$joinMethod}("$relatedTable AS $alias", "$relatedTable.$relationKey",'=',"$pivotLocalKey");
        $query->distinct();

        $this->joinClasses[$name] = $related;
        $this->joinTable[$name] = $relatedTable;
        $this->joinAliases[$name] = $alias;

    }

    protected function joinNameToAlias($join){
        return str_replace($this->parser->joinDelimiter,'__', $join);
    }

    protected function joinColumn($join, $column){
        return str_replace($this->parser->joinDelimiter,'__', $join).".$column";
    }

    public function getColumns()
    {
        return $this->columns;
    }

    public function getQueryColumns()
    {
        if (!$this->columns) {
            return $this->getDefaultColumns();
        }

        $queryColumns = [];

        $knownColumns = $this->mergedQueryColumns();

        $table = $this->model->getTable();

        $modelKey = $this->model()->getKeyName();

        if (!in_array($modelKey, $knownColumns)) {
            $queryColumns[] = "$table.$modelKey";
        }

        foreach ($knownColumns as $key) {

            // Relations will get fetched by with()
            if ($this->isRelatedKey($key)) {
                continue;
            }

            // Relations will get fetched by with()
            if ($this->isRelation($key)) {
                continue;
            }

            if ($this->parser->isRelatedKey($key)) {
                $queryColumns[] = $key;
                continue;
            }

            $queryColumns[] = "$table.$key";

        }

        return $queryColumns;

    }

    public function mergedQueryColumns()
    {

        $queryColumns = (array)$this->columns;

        foreach ($this->onlyQueryColumns as $column) {
            if (!in_array($column, $queryColumns)) {
                $queryColumns[] = $column;
            }
        }

        return $queryColumns;
    }

    public function leftJoinOn($path)
    {
        $this->joinMethods[$path] = 'left';
        return $this;
    }

    public function rightJoinOn($path)
    {
        $this->joinMethods[$path] = 'right';
        return $this;
    }

    public function outerJoinOn($path)
    {
        $this->joinMethods[$path] = 'outer';
        return $this;
    }

    public function innerJoinOn($path)
    {
        $this->joinMethods[$path] = 'outer';
        return $this;
    }

    public function getJoinMethod($path)
    {
        if (!isset($this->joinMethods[$path])) {
            return 'join';
        }

        return $this->joinMethods[$path] . 'Join';

    }

    public function addQueryColumn($column)
    {
        $this->onlyQueryColumns[] = $column;
        return $this;
    }

    public function getDefaultColumns(){
        return [$this->model->getTable().'.*'];
    }

    /**
     * Find a model by its primary key.
     *
     * @param  mixed  $id
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Model|static|null
     */
    public function find($id, $columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->find($id, $columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->find($id, $this->getQueryColumns());

    }

    /**
     * Find a model by its primary key.
     *
     * @param  array  $id
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Model|Collection|static
     */
    public function findMany($id, $columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->findMany($id, $columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->findMany($id, $this->getQueryColumns());

    }

    /**
     * Find a model by its primary key or throw an exception.
     *
     * @param  mixed  $id
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Model|static
     *
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
     */
    public function findOrFail($id, $columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->findOrFail($id, $columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->findOrFail($id, $this->getQueryColumns());

    }

    /**
     * Execute the query and get the first result.
     *
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Model|static|null
     */
    public function first($columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->first($columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->first($this->getQueryColumns());

    }

    /**
     * Execute the query and get the first result or throw an exception.
     *
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Model|static
     *
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
     */
    public function firstOrFail($columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->firstOrFail($columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->firstOrFail($this->getQueryColumns());

    }

    /**
     * Execute the query as a "select" statement.
     *
     * @param  array  $columns
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function get($columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if (!$columnsPassed) {
            // addJoinOnce adds queryColumns again...
            return $query->get($this->getQueryColumns());
        }

        if (!$columns) {
            return $query->get();
        }

        return $query->get($columns);

    }

    /**
     * Pluck a single column from the database.
     *
     * @param  string  $column
     * @return mixed
     */
    public function pluck($column)
    {
        return $this->buildQuery([$column])->pluck($column);
    }

    /**
     * Chunk the results of the query.
     *
     * @param  int  $count
     * @param  callable  $callback
     * @return void
     */
    public function chunk($count, callable $callback){

        return $this->buildQuery($this->getQueryColumns())->chunk($count, $callback);
    }

    /**
     * Get an array with the values of a given column.
     *
     * @param  string  $column
     * @param  string  $key
     * @return array
     */
    public function lists($column, $key = null){
        return $this->buildQuery([$column])->lists($column, $key);
    }

    /**
     * Get a paginator for the "select" statement.
     *
     * @param  int    $perPage
     * @param  array  $columns
     * @return \Illuminate\Pagination\Paginator
     */
    public function paginate($perPage = null, $columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1) && ($columns !== null);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->paginate($perPage, $columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->paginate($perPage, $this->getQueryColumns());

    }

    /**
     * Get a paginator only supporting simple next and previous links.
     *
     * This is more efficient on larger data-sets, etc.
     *
     * @param  int    $perPage
     * @param  array  $columns
     * @return \Illuminate\Pagination\Paginator
     */
    public function simplePaginate($perPage = null, $columns = array('*'))
    {

        $columnsPassed = (func_num_args() > 1);

        $columns = $columnsPassed ? $columns : $this->getQueryColumns();

        $query = $this->buildQuery($columns);

        if ($columnsPassed) {
            return $query->simplePaginate($perPage, $columns);
        }

        // addJoinOnce adds queryColumns again...
        return $query->simplePaginate($perPage, $this->getQueryColumns());

    }

    public function toSql(){
        return $this->buildQuery($this->getQueryColumns())->toSql();
    }

    public function model()
    {
        return $this->model;
    }

    public function modelClass()
    {
        return get_class($this->model);
    }
}