Browse Source

fixes for 3.1

Mark Scherer 10 years ago
parent
commit
b5a1a78b18

+ 1 - 1
composer.json

@@ -14,7 +14,7 @@
 	],
 	"require":{
 		"php": ">=5.4",
-		"cakephp/cakephp": "~3.0",
+		"cakephp/cakephp": "~3.1",
 		"dereuromark/cakephp-shim": "~1.0"
 	},
 	"require-dev":{

+ 15 - 11
src/Network/Email/Email.php

@@ -381,10 +381,10 @@ class Email extends CakeEmail {
 			//$this->_headers['Importance'] = 'High';
 		}
 
-		// if not live, just log but do not send any mails
-		if (! Configure::read('Config.live')) {
-        	$this->_logEmail();
-        	return true;
+		// if not live, just log but do not send any mails //TODO: remove and use Debug Transport!
+		if (!Configure::read('Config.live')) {
+			$this->_logEmail();
+			return true;
 		}
 
 		// Security measure to not sent to the actual addressee in debug mode while email sending is live
@@ -430,25 +430,29 @@ class Email extends CakeEmail {
 
 			// log error
 			$this->log($this->_error, LogLevel::ERROR);
-			
+
 			return false;
 		}
 
-		if ( $this->_profile['logReport'] ) {
+		if (!empty($this->_profile['logReport'])) {
 			$this->_logEmail();
 		}
 
 		return true;
 	}
 
+	/**
+	 * @param string $level
+	 * @return void
+	 */
 	protected function _logEmail($level = LogLevel::INFO)
 	{
 		$content =
-			$this->_log['transport'] .
-			' - ' . 'TO:' . implode(',', array_keys($this->_log['to'])) .
-			'||FROM:' . implode(',', array_keys($this->_log['from'])) .
-			'||REPLY:' . implode(',', array_keys($this->_log['replyTo'])) .
-			'||S:' . $this->_log['subject'];
+			$this->_log['transport'] . (!Configure::read('Config.live') ? ' (simulated)' : '')
+			. ' - ' . 'TO:' . implode(',', array_keys($this->_log['to']))
+			. '||FROM:' . implode(',', array_keys($this->_log['from']))
+			. '||REPLY:' . implode(',', array_keys($this->_log['replyTo']))
+			. '||S:' . $this->_log['subject'];
 
 		$this->log($content, $level);
 	}

+ 2 - 2
src/View/Helper/FormatHelper.php

@@ -3,7 +3,7 @@ namespace Tools\View\Helper;
 
 use Cake\Core\Configure;
 use Cake\Utility\Inflector;
-use Cake\View\Helper\TextHelper;
+use Cake\View\Helper;
 use Cake\View\StringTemplate;
 use Cake\View\View;
 
@@ -15,7 +15,7 @@ use Cake\View\View;
  * @author Mark Scherer
  * @license MIT
  */
-class FormatHelper extends TextHelper {
+class FormatHelper extends Helper {
 
 	/**
 	 * Other helpers used by FormHelper

+ 1 - 1
src/View/Helper/NumberHelper.php

@@ -19,7 +19,7 @@ class NumberHelper extends CakeNumberHelper {
 	 *            The class needs to be placed in the `Utility` directory.
 	 *
 	 * @param \Cake\View\View $View The View this helper is being attached to.
-	 * @param array $config Configuration settings for the helper
+	 * @param array $options Configuration settings for the helper
 	 * @throws \Cake\Core\Exception\Exception When the engine class could not be found.
 	 */
 	public function __construct($View = null, $options = []) {

+ 1 - 1
src/View/Helper/TextHelper.php

@@ -36,7 +36,7 @@ class TextHelper extends CakeTextHelper {
 	 *
 	 * @param View $View the view object the helper is attached to.
 	 * @param array $settings Settings array Settings array
-	 * @throws CakeException when the engine class could not be found.
+	 * @throws \Cake\Core\Exception\Exception when the engine class could not be found.
 	 */
 	public function __construct(View $View, array $config = []) {
 		$config = Hash::merge(['engine' => 'Tools.Text'], $config);

+ 29 - 5
src/View/Helper/TimeHelper.php

@@ -66,14 +66,32 @@ class TimeHelper extends CakeTimeHelper {
 	}
 
 	/**
+	 * Returns a nicely formatted date string for given Datetime string.
+	 *
+	 * @param int|string|\DateTime|null $dateString UNIX timestamp, strtotime() valid string or DateTime object
+	 * @param string|\DateTimeZone|null $timezone User's timezone string or DateTimeZone object
+	 * @param string|null $locale Locale string.
+	 * @param string|bool $default Default string to use when no dateString is given. Use false to allow null as current date.
+	 * @return string Formatted date string
+	 */
+	public function nice($dateString = null, $timezone = null, $locale = null, $default = '') {
+		if ($dateString === null && $default !== false) {
+			return $default;
+		}
+		return parent::nice($dateString, $timezone, $locale);
+	}
+
+	/**
 	 * Output the age of a person within a sane range.
 	 * Defaults to the $default string if outside of that range.
 	 *
-	 * @param string date (from db)
+	 * @param null $date
+	 * @param string|bool $default
 	 * @return int age on success, mixed $default otherwise
+	 * @internal param date $string
 	 */
-	public function userAge($date = null, $default = '---') {
-		if ((int)$date === 0) {
+	public function userAge($date = null, $default = '') {
+		if ($date === null) {
 			return $default;
 		}
 		$age = $this->age($date, null);
@@ -86,6 +104,9 @@ class TimeHelper extends CakeTimeHelper {
 	/**
 	 * Like localDate(), only with additional markup <span> and class="today", if today, etc
 	 *
+	 * @param null $dateString
+	 * @param null $format
+	 * @param array $options
 	 * @return string
 	 */
 	public function localDateMarkup($dateString = null, $format = null, $options = []) {
@@ -97,6 +118,9 @@ class TimeHelper extends CakeTimeHelper {
 	/**
 	 * Like niceDate(), only with additional markup <span> and class="today", if today, etc
 	 *
+	 * @param null $dateString
+	 * @param null $format
+	 * @param array $options
 	 * @return string
 	 */
 	public function niceDateMarkup($dateString = null, $format = null, $options = []) {
@@ -113,9 +137,9 @@ class TimeHelper extends CakeTimeHelper {
 	 * ...
 	 * @param array $options
 	 * @param array $attr: html attributes
-	 * @return nicely formatted date
+	 * @return string Nicely formatted date
 	 */
-	public function published(\DateTime $date, $options = [], $attr = []) {
+	public function published(\DateTime $date, array $options = [], array $attr = []) {
 		$niceDate = '';
 		$when = null;
 		$span = '';