Skip to content

Commit

Permalink
Bundle 0.2.1 (#10)
Browse files Browse the repository at this point in the history
Bundle 0.2.1
  • Loading branch information
kaioken committed May 11, 2019
2 parents d1bff4c + 31c5323 commit 6333b47
Show file tree
Hide file tree
Showing 10 changed files with 642 additions and 331 deletions.
35 changes: 19 additions & 16 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#DOCKER
COMPOSE_PROJECT_NAME=baka-mail

PRODUCTION=0

# Email
EMAIL_HOST=smtp.mailgun.org
EMAIL_PORT=587
EMAIL_USER=
EMAIL_PASS=
EMAIL_FROM_PRODUCTION=[email protected]
EMAIL_FROM_NAME_PRODUCTION="Baka Canvas"
EMAIL_FROM_DEBUG=[email protected]
EMAIL_FROM_NAME_DEBUG="Baka Canvas"
CACHE_PREFIX=api_cache_
CACHE_LIFETIME=86400

# Redis
REDIS_HOST=redis
REDIS_PORT=6379
# Memcached
DATA_API_MEMCACHED_HOST=memcached
DATA_API_MEMCACHED_PORT=11211
DATA_API_MEMCACHED_WEIGHT=100

# Beanstalk
BEANSTALK_HOST=beanstalkd
BEANSTALK_PORT=11300
BEANSTALK_PREFIX=canvas_
# Beanstalkd
DATA_API_BEANSTALK_HOST=beanstalkd
DATA_API_BEANSTALK_PORT=11300
DATA_API_BEANSTALK_PREFIX=

# Email
DATA_API_EMAIL_HOST=
DATA_API_EMAIL_PORT=587
DATA_API_EMAIL_USER=
DATA_API_EMAIL_PASS=
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
"ext-phalcon": ">=3.0.0",
"phalcon/incubator": ">=3.0",
"duncan3dc/fork-helper": "^2.2.0",
"swiftmailer/swiftmailer": "^6"
"swiftmailer/swiftmailer": "^6",
"symfony/var-dumper": "^4.2"
},
"require-dev": {
"codeception/verify": "*",
"vlucas/phpdotenv": "^2.0",
"codeception/codeception": "2.4"
"codeception/codeception": "2.5.*",
"codeception/verify": "0.4.0",
"vlucas/phpdotenv": "^2.0"
},
"scripts": {
"test": "./vendor/bin/codecept run"
},
"autoload": {
"psr-4": {
Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3"

services:

phalcon:
image: mctekk/phalconphp:latest
volumes:
- .:/app
tty: true
ports:
- "9000:9000"
networks:
- local-network

memcached:
image: memcached
ports:
- "11211:11211"
networks:
- local-network

beanstalkd:
image: schickling/beanstalkd:latest
restart: always
ports:
- "11300:11300"
networks:
- local-network

volumes:
db-data:

networks:
local-network:
21 changes: 6 additions & 15 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Message extends \Phalcon\Mailer\Message
{
protected $queueName = 'email_queue';
protected $viewPath = null;
protected $params = null;
protected $params = [];
protected $viewsDirLocal = null;
protected $smtp = null;
protected $auth = false;
Expand All @@ -34,7 +34,7 @@ class Message extends \Phalcon\Mailer\Message
*/
public function content($content, $contentType = self::CONTENT_TYPE_HTML, $charset = null)
{
if (isset($this->params) && is_array($this->params)) {
if ($this->params) {
$content = $this->setDynamicContent($this->params, $content);
}

Expand Down Expand Up @@ -79,7 +79,6 @@ public function send()

//send to queue
$queue = $this->getManager()->getQueue();
//$queueName = $this->

if ($this->auth) {
$queue->putInTube($this->queueName, [
Expand All @@ -90,11 +89,6 @@ public function send()
$queue->putInTube($this->queueName, $this->getMessage());
}

/* $count = $this->getManager()->getSwift()->send($this->getMessage(), $this->failedRecipients);
if ($eventManager) {
$eventManager->fire('mailer:afterSend', $this, [$count, $this->failedRecipients]);
}
return $count;*/
}

/**
Expand Down Expand Up @@ -153,7 +147,7 @@ public function smtp(array $params)
*
* @return $this
*/
public function queue($queue)
public function queue(string $queue)
{
$this->queueName = $queue;
return $this;
Expand All @@ -166,7 +160,7 @@ public function queue($queue)
*
* @return $this
*/
public function params($params)
public function params(array $params)
{
$this->params = $params;
return $this;
Expand All @@ -179,7 +173,7 @@ public function params($params)
*
* @return $this
*/
public function viewDir($dir)
public function viewDir(string $dir)
{
$this->viewsDirLocal = $dir;
return $this;
Expand All @@ -196,10 +190,7 @@ public function template($template = 'email.volt')
{
$this->viewPath = $template;

//if we have params thats means we are using a template
if (is_array($this->params)) {
$content = $this->getManager()->setRenderView($this->viewPath, $this->params);
}
$content = $this->getManager()->setRenderView($this->viewPath, $this->params);

$this->getMessage()->setBody($content, self::CONTENT_TYPE_HTML);

Expand Down
Loading

0 comments on commit 6333b47

Please sign in to comment.