[TASK] Convert to PSR-2 06/46906/2
authorStefan Froemken <froemken@gmail.com>
Fri, 26 Feb 2016 09:58:42 +0000 (10:58 +0100)
committerFrancois Suter <francois@typo3.org>
Fri, 26 Feb 2016 10:10:20 +0000 (11:10 +0100)
Resolves: #73690
Releases: master

Change-Id: I4297a2b324f3bd6f83c8c27a8a3c2c9ffdb6425a
Reviewed-on: https://review.typo3.org/46906
Reviewed-by: Francois Suter <francois@typo3.org>
Tested-by: Francois Suter <francois@typo3.org>
15 files changed:
Classes/Domain/Model/Entry.php
Classes/Domain/Repository/EntryRepository.php
Classes/Utility/Logger.php
Classes/Utility/TceForms.php
Classes/Writer/AbstractWriter.php
Classes/Writer/DatabaseWriter.php
Classes/Writer/FileWriter.php
Classes/Writer/WriterInterface.php
Configuration/TCA/tx_devlog_domain_model_entry.php
Tests/Unit/Domain/Model/EntryTest.php
Tests/Unit/Utility/LoggerTest.php
ext_emconf.php
ext_localconf.php
ext_tables.php
ext_tables.sql

index 8f88436..e1fc554 100644 (file)
@@ -18,305 +18,330 @@ namespace Devlog\Devlog\Domain\Model;
  *
  * @author Francois Suter <typo3@cobweb.ch>
  */
-class Entry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
-
-       /**
-        * Unique ID of the run this entry belongs to.
-        *
-        * @var string
-        */
-       protected $runId = '';
-
-       /**
-        * Entry order within the log run.
-        *
-        * @var int
-        */
-       protected $sorting = 0;
-
-       /**
-        * Timestamp of the log run.
-        *
-        * @var integer
-        */
-       protected $crdate = 0;
-
-       /**
-        * Severity.
-        *
-        * @var integer
-        */
-       protected $severity = 0;
-
-       /**
-        * Extension key or some other identification key.
-        *
-        * @var string
-        */
-       protected $extkey = '';
-
-       /**
-        * Message.
-        *
-        * @var string
-        */
-       protected $message = '';
-
-       /**
-        * Call location (file).
-        *
-        * @var string
-        */
-       protected $location = '';
-
-       /**
-        * Call line.
-        *
-        * @var integer
-        */
-       protected $line = 0;
-
-       /**
-        * Referring IP address.
-        *
-        * @var string
-        */
-       protected $ip = '';
-
-       /**
-        * Logged in BE user at the creation of the log entry (if any).
-        *
-        * @var int
-        */
-       protected $cruserId = 0;
-
-       /**
-        * Page where the data was logged (if applicable).
-        *
-        * @var int
-        */
-       protected $pid = 0;
-
-       /**
-        * extraData
-        *
-        * @var mixed
-        */
-       protected $extraData = NULL;
-
-       /**
-        * Gets the run ID.
-        *
-        * @return string
-        */
-       public function getRunId() {
-               return $this->runId;
-       }
-
-       /**
-        * Sets the run ID.
-        *
-        * @param string $runId
-        */
-       public function setRunId($runId) {
-               $this->runId = $runId;
-       }
-
-       /**
-        * Returns the sorting.
-        *
-        * @return int
-        */
-       public function getSorting() {
-               return $this->sorting;
-       }
-
-       /**
-        * Sets the sorting.
-        *
-        * @param int $sorting
-        */
-       public function setSorting($sorting) {
-               $this->sorting = $sorting;
-       }
-
-       /**
-        * Returns the creation date.
-        *
-        * @return int
-        */
-       public function getCrdate() {
-               return $this->crdate;
-       }
-
-       /**
-        * Sets the creation date.
-        *
-        * @param int $crDate
-        */
-       public function setCrdate($crDate) {
-               $this->crdate = $crDate;
-       }
-
-       /**
-        * Returns the severity
-        *
-        * @return integer $severity
-        */
-       public function getSeverity() {
-               return $this->severity;
-       }
-
-       /**
-        * Sets the severity
-        *
-        * @param integer $severity
-        * @return void
-        */
-       public function setSeverity($severity) {
-               $this->severity = $severity;
-       }
-
-       /**
-        * Returns the extkey
-        *
-        * @return string $extkey
-        */
-       public function getExtkey() {
-               return $this->extkey;
-       }
-
-       /**
-        * Sets the extkey
-        *
-        * @param string $extkey
-        * @return void
-        */
-       public function setExtkey($extkey) {
-               $this->extkey = $extkey;
-       }
-
-       /**
-        * Returns the message
-        *
-        * @return string $message
-        */
-       public function getMessage() {
-               return $this->message;
-       }
-
-       /**
-        * Sets the message
-        *
-        * @param string $message
-        * @return void
-        */
-       public function setMessage($message) {
-               $this->message = $message;
-       }
-
-       /**
-        * Returns the location
-        *
-        * @return string $location
-        */
-       public function getLocation() {
-               return $this->location;
-       }
-
-       /**
-        * Sets the location
-        *
-        * @param string $location
-        * @return void
-        */
-       public function setLocation($location) {
-               $this->location = $location;
-       }
-
-       /**
-        * Returns the line
-        *
-        * @return integer $line
-        */
-       public function getLine() {
-               return $this->line;
-       }
-
-       /**
-        * Sets the line
-        *
-        * @param integer $line
-        * @return void
-        */
-       public function setLine($line) {
-               $this->line = $line;
-       }
-
-       /**
-        * Returns the ip
-        *
-        * @return string $ip
-        */
-       public function getIp() {
-               return $this->ip;
-       }
-
-       /**
-        * Sets the ip
-        *
-        * @param string $ip
-        * @return void
-        */
-       public function setIp($ip) {
-               $this->ip = $ip;
-       }
-
-       /**
-        * @return int
-        */
-       public function getCruserId() {
-               return $this->cruserId;
-       }
-
-       /**
-        * @param int $cruserId
-        */
-       public function setCruserId($cruserId) {
-               $this->cruserId = $cruserId;
-       }
-
-       /**
-        * @return int
-        */
-       public function getPid() {
-               return $this->pid;
-       }
-
-       /**
-        * @param int $pid
-        */
-       public function setPid($pid) {
-               $this->pid = $pid;
-       }
-
-       /**
-        * Returns the extraData
-        *
-        * @return mixed $extraData
-        */
-       public function getExtraData() {
-               return $this->extraData;
-       }
-
-       /**
-        * Sets the extraData
-        *
-        * @param mixed $extraData
-        * @return void
-        */
-       public function setExtraData($extraData) {
-               $this->extraData = $extraData;
-       }
+class Entry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+{
+
+    /**
+     * Unique ID of the run this entry belongs to.
+     *
+     * @var string
+     */
+    protected $runId = '';
+
+    /**
+     * Entry order within the log run.
+     *
+     * @var int
+     */
+    protected $sorting = 0;
+
+    /**
+     * Timestamp of the log run.
+     *
+     * @var integer
+     */
+    protected $crdate = 0;
+
+    /**
+     * Severity.
+     *
+     * @var integer
+     */
+    protected $severity = 0;
+
+    /**
+     * Extension key or some other identification key.
+     *
+     * @var string
+     */
+    protected $extkey = '';
+
+    /**
+     * Message.
+     *
+     * @var string
+     */
+    protected $message = '';
+
+    /**
+     * Call location (file).
+     *
+     * @var string
+     */
+    protected $location = '';
+
+    /**
+     * Call line.
+     *
+     * @var integer
+     */
+    protected $line = 0;
+
+    /**
+     * Referring IP address.
+     *
+     * @var string
+     */
+    protected $ip = '';
+
+    /**
+     * Logged in BE user at the creation of the log entry (if any).
+     *
+     * @var int
+     */
+    protected $cruserId = 0;
+
+    /**
+     * Page where the data was logged (if applicable).
+     *
+     * @var int
+     */
+    protected $pid = 0;
+
+    /**
+     * extraData
+     *
+     * @var mixed
+     */
+    protected $extraData = NULL;
+
+    /**
+     * Gets the run ID.
+     *
+     * @return string
+     */
+    public function getRunId()
+    {
+        return $this->runId;
+    }
+
+    /**
+     * Sets the run ID.
+     *
+     * @param string $runId
+     */
+    public function setRunId($runId)
+    {
+        $this->runId = $runId;
+    }
+
+    /**
+     * Returns the sorting.
+     *
+     * @return int
+     */
+    public function getSorting()
+    {
+        return $this->sorting;
+    }
+
+    /**
+     * Sets the sorting.
+     *
+     * @param int $sorting
+     */
+    public function setSorting($sorting)
+    {
+        $this->sorting = $sorting;
+    }
+
+    /**
+     * Returns the creation date.
+     *
+     * @return int
+     */
+    public function getCrdate()
+    {
+        return $this->crdate;
+    }
+
+    /**
+     * Sets the creation date.
+     *
+     * @param int $crDate
+     */
+    public function setCrdate($crDate)
+    {
+        $this->crdate = $crDate;
+    }
+
+    /**
+     * Returns the severity
+     *
+     * @return integer $severity
+     */
+    public function getSeverity()
+    {
+        return $this->severity;
+    }
+
+    /**
+     * Sets the severity
+     *
+     * @param integer $severity
+     * @return void
+     */
+    public function setSeverity($severity)
+    {
+        $this->severity = $severity;
+    }
+
+    /**
+     * Returns the extkey
+     *
+     * @return string $extkey
+     */
+    public function getExtkey()
+    {
+        return $this->extkey;
+    }
+
+    /**
+     * Sets the extkey
+     *
+     * @param string $extkey
+     * @return void
+     */
+    public function setExtkey($extkey)
+    {
+        $this->extkey = $extkey;
+    }
+
+    /**
+     * Returns the message
+     *
+     * @return string $message
+     */
+    public function getMessage()
+    {
+        return $this->message;
+    }
+
+    /**
+     * Sets the message
+     *
+     * @param string $message
+     * @return void
+     */
+    public function setMessage($message)
+    {
+        $this->message = $message;
+    }
+
+    /**
+     * Returns the location
+     *
+     * @return string $location
+     */
+    public function getLocation()
+    {
+        return $this->location;
+    }
+
+    /**
+     * Sets the location
+     *
+     * @param string $location
+     * @return void
+     */
+    public function setLocation($location)
+    {
+        $this->location = $location;
+    }
+
+    /**
+     * Returns the line
+     *
+     * @return integer $line
+     */
+    public function getLine()
+    {
+        return $this->line;
+    }
+
+    /**
+     * Sets the line
+     *
+     * @param integer $line
+     * @return void
+     */
+    public function setLine($line)
+    {
+        $this->line = $line;
+    }
+
+    /**
+     * Returns the ip
+     *
+     * @return string $ip
+     */
+    public function getIp()
+    {
+        return $this->ip;
+    }
+
+    /**
+     * Sets the ip
+     *
+     * @param string $ip
+     * @return void
+     */
+    public function setIp($ip)
+    {
+        $this->ip = $ip;
+    }
+
+    /**
+     * @return int
+     */
+    public function getCruserId()
+    {
+        return $this->cruserId;
+    }
+
+    /**
+     * @param int $cruserId
+     */
+    public function setCruserId($cruserId)
+    {
+        $this->cruserId = $cruserId;
+    }
+
+    /**
+     * @return int
+     */
+    public function getPid()
+    {
+        return $this->pid;
+    }
+
+    /**
+     * @param int $pid
+     */
+    public function setPid($pid)
+    {
+        $this->pid = $pid;
+    }
+
+    /**
+     * Returns the extraData
+     *
+     * @return mixed $extraData
+     */
+    public function getExtraData()
+    {
+        return $this->extraData;
+    }
+
+    /**
+     * Sets the extraData
+     *
+     * @param mixed $extraData
+     * @return void
+     */
+    public function setExtraData($extraData)
+    {
+        $this->extraData = $extraData;
+    }
 
 }
\ No newline at end of file
index 9d37b7e..87ead8f 100644 (file)
@@ -13,6 +13,8 @@ namespace Devlog\Devlog\Domain\Repository;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\SingletonInterface;
+
 /**
  * The repository for DevLog Entries.
  *
@@ -21,142 +23,148 @@ namespace Devlog\Devlog\Domain\Repository;
  *
  * @author Francois Suter <typo3@cobweb.ch>
  */
-class EntryRepository implements \TYPO3\CMS\Core\SingletonInterface {
-       /**
-        * @var string Name of the database table used for logging
-        */
-       protected $databaseTable = 'tx_devlog_domain_model_entry';
+class EntryRepository implements SingletonInterface
+{
+    /**
+     * @var string Name of the database table used for logging
+     */
+    protected $databaseTable = 'tx_devlog_domain_model_entry';
 
-       /**
-        * @var array Extension configuration
-        */
-       protected $extensionConfiguration;
+    /**
+     * @var array Extension configuration
+     */
+    protected $extensionConfiguration = NULL;
 
-       /**
-        * @var integer Number of rows in the database (cached to avoid querying too often)
-        */
-       protected $numberOfRows = NULL;
+    /**
+     * @var integer Number of rows in the database (cached to avoid querying too often)
+     */
+    protected $numberOfRows = NULL;
 
-       /**
-        * Returns all available records in the log table.
-        *
-        * By default records are sorted by descending creation date and
-        * ascending order.
-        *
-        * @return array|NULL
-        */
-       public function findAll() {
-               $entries = $this->getDatabaseConnection()->exec_SELECTgetRows(
-                       '*',
-                       $this->databaseTable,
-                       '',
-                       '',
-                       'crdate DESC, sorting ASC'
-               );
-               $numEntries = count($entries);
-               for ($i = 0; $i < $numEntries; $i++) {
-                       $entries[$i]['extra_data'] = gzuncompress($entries[$i]['extra_data']);
-               }
-       }
+    /**
+     * Returns all available records in the log table.
+     *
+     * By default records are sorted by descending creation date and
+     * ascending order.
+     *
+     * @return array|NULL
+     */
+    public function findAll()
+    {
+        $entries = $this->getDatabaseConnection()->exec_SELECTgetRows(
+            '*',
+            $this->databaseTable,
+            '',
+            '',
+            'crdate DESC, sorting ASC'
+        );
+        $numEntries = count($entries);
+        for ($i = 0; $i < $numEntries; $i++) {
+            $entries[$i]['extra_data'] = gzuncompress($entries[$i]['extra_data']);
+        }
+    }
 
-       /**
-        * Adds a log entry to the database table.
-        *
-        * @param \Devlog\Devlog\Domain\Model\Entry $entry
-        * @return boolean
-        */
-       public function add($entry) {
-               $fields = array(
-                       'run_id' => $entry->getRunId(),
-                       'sorting' => $entry->getSorting(),
-                       'severity' => $entry->getSeverity(),
-                       'extkey' => $entry->getExtkey(),
-                       'message' => $entry->getMessage(),
-                       'location' => $entry->getLocation(),
-                       'line' => $entry->getLine(),
-                       'ip' => $entry->getIp(),
-                       'cruser_id' => $entry->getCruserId(),
-                       'crdate' => $entry->getCrdate(),
-                       'pid' => $entry->getPid(),
-               );
-               // Handle extra data
-               $fields['extra_data'] = gzcompress(serialize($entry->getExtraData()));
-               $extraDataSize = strlen($fields['extra_data']);
-               $maximumExtraDataSize = $this->extensionConfiguration['maximumExtraDataSize'];
-               // If the entry's extra data is above the limit, replace it with a warning
-               if (!empty($maximumExtraDataSize) && $extraDataSize > $maximumExtraDataSize) {
-                       $fields['extra_data'] = gzcompress(serialize('Extra data too large, not saved.'));
-               }
-               return $this->getDatabaseConnection()->exec_INSERTquery(
-                       $this->databaseTable,
-                       $fields
-               );
-       }
+    /**
+     * Adds a log entry to the database table.
+     *
+     * @param \Devlog\Devlog\Domain\Model\Entry $entry
+     * @return boolean
+     */
+    public function add($entry)
+    {
+        $fields = array(
+            'run_id' => $entry->getRunId(),
+            'sorting' => $entry->getSorting(),
+            'severity' => $entry->getSeverity(),
+            'extkey' => $entry->getExtkey(),
+            'message' => $entry->getMessage(),
+            'location' => $entry->getLocation(),
+            'line' => $entry->getLine(),
+            'ip' => $entry->getIp(),
+            'cruser_id' => $entry->getCruserId(),
+            'crdate' => $entry->getCrdate(),
+            'pid' => $entry->getPid(),
+        );
+        // Handle extra data
+        $fields['extra_data'] = gzcompress(serialize($entry->getExtraData()));
+        $extraDataSize = strlen($fields['extra_data']);
+        $maximumExtraDataSize = $this->extensionConfiguration['maximumExtraDataSize'];
+        // If the entry's extra data is above the limit, replace it with a warning
+        if (!empty($maximumExtraDataSize) && $extraDataSize > $maximumExtraDataSize) {
+            $fields['extra_data'] = gzcompress(serialize('Extra data too large, not saved.'));
+        }
+        return $this->getDatabaseConnection()->exec_INSERTquery(
+            $this->databaseTable,
+            $fields
+        );
+    }
 
-       /**
-        * Enforces the limits set in the extension configuration to avoid that the DB tables gets out of hand.
-        *
-        * @return void
-        */
-       public function cleanUp() {
-               // Get the total number of rows, if not already defined
-               if ($this->numberOfRows === NULL) {
-                       $this->numberOfRows = $this->getDatabaseConnection()->exec_SELECTcountRows(
-                               'uid',
-                               'tx_devlog_domain_model_entry'
-                       );
-               }
-               // Check if number of rows is above the limit and clean up if necessary
-               if ($this->numberOfRows > $this->extensionConfiguration['maximumRows']) {
-                       // Select the row from which to start cleaning up
-                       // To achieve this, order by creation date (so oldest come first)
-                       // then offset by 10% of maximumRows and get the next record
-                       // This will return a timestamp that is used as a cut-off date
-                       $numberOfRowsToRemove = round(0.1 * $this->extensionConfiguration['maximumRows']);
-                       $cutOffRow = $this->getDatabaseConnection()->exec_SELECTgetRows(
-                               'crdate',
-                               'tx_devlog_domain_model_entry',
-                               '',
-                               '',
-                               'crdate',
-                               $numberOfRowsToRemove . ',1'
-                       );
-                       $cutOffDate = $cutOffRow[0]['crdate'];
-                       // Delete all rows older or same age as previously found timestamp
-                       // This will probably delete a bit more than 10% of maximumRows, but will at least
-                       // delete complete log runs
-                       $this->getDatabaseConnection()->exec_DELETEquery(
-                               'tx_devlog_domain_model_entry',
-                               'crdate <= \'' . $cutOffDate . '\''
-                       );
-                       $numberOfRemovedRows = $this->getDatabaseConnection()->sql_affected_rows();
-                       // Update (cached) number of rows
-                       $this->numberOfRows -= $numberOfRemovedRows;
-                       // Optimize the table (if option is active)
-                       if ($this->extensionConfiguration['optimize']) {
-                               $this->getDatabaseConnection()->sql_query('OPTIMIZE table tx_devlog_domain_model_entry');
-                       }
-               }
+    /**
+     * Enforces the limits set in the extension configuration to avoid that the DB tables gets out of hand.
+     *
+     * @return void
+     */
+    public function cleanUp()
+    {
+        // Get the total number of rows, if not already defined
+        if ($this->numberOfRows === NULL) {
+            $this->numberOfRows = $this->getDatabaseConnection()->exec_SELECTcountRows(
+                'uid',
+                'tx_devlog_domain_model_entry'
+            );
+        }
+        // Check if number of rows is above the limit and clean up if necessary
+        if ($this->numberOfRows > $this->extensionConfiguration['maximumRows']) {
+            // Select the row from which to start cleaning up
+            // To achieve this, order by creation date (so oldest come first)
+            // then offset by 10% of maximumRows and get the next record
+            // This will return a timestamp that is used as a cut-off date
+            $numberOfRowsToRemove = round(0.1 * $this->extensionConfiguration['maximumRows']);
+            $cutOffRow = $this->getDatabaseConnection()->exec_SELECTgetRows(
+                'crdate',
+                'tx_devlog_domain_model_entry',
+                '',
+                '',
+                'crdate',
+                $numberOfRowsToRemove . ',1'
+            );
+            $cutOffDate = $cutOffRow[0]['crdate'];
+            // Delete all rows older or same age as previously found timestamp
+            // This will probably delete a bit more than 10% of maximumRows, but will at least
+            // delete complete log runs
+            $this->getDatabaseConnection()->exec_DELETEquery(
+                'tx_devlog_domain_model_entry',
+                'crdate <= \'' . $cutOffDate . '\''
+            );
+            $numberOfRemovedRows = $this->getDatabaseConnection()->sql_affected_rows();
+            // Update (cached) number of rows
+            $this->numberOfRows -= $numberOfRemovedRows;
+            // Optimize the table (if option is active)
+            if ($this->extensionConfiguration['optimize']) {
+                $this->getDatabaseConnection()->sql_query('OPTIMIZE table tx_devlog_domain_model_entry');
+            }
+        }
 
-       }
+    }
 
-       /**
-        * Sets the extension configuration.
-        *
-        * Used to pass the "devlog" configuration down to the entry repository.
-        *
-        * @param array $configuration
-        */
-       public function setExtensionConfiguration($configuration) {
-               $this->extensionConfiguration = $configuration;
-       }
+    /**
+     * Sets the extension configuration.
+     *
+     * Used to pass the "devlog" configuration down to the entry repository.
+     *
+     * @param array $configuration
+     */
+    public function setExtensionConfiguration($configuration)
+    {
+        $this->extensionConfiguration = $configuration;
+    }
 
-       /**
-        * Wrapper around the global database object.
-        *
-        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected function getDatabaseConnection() {
-               return $GLOBALS['TYPO3_DB'];
-       }
+    /**
+     * Wrapper around the global database object.
+     *
+     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+     */
+    protected function getDatabaseConnection()
+    {
+        return $GLOBALS['TYPO3_DB'];
+    }
 }
\ No newline at end of file
index 9b92124..31ec6e8 100644 (file)
@@ -15,6 +15,7 @@ namespace Devlog\Devlog\Utility;
  */
 
 use Devlog\Devlog\Writer\WriterInterface;
+use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -24,237 +25,247 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * @author Francois Suter <typo3@cobweb.ch>
  */
-class Logger implements \TYPO3\CMS\Core\SingletonInterface {
-       /**
-        * @var array Devlog extension configuration
-        */
-       protected $extensionConfiguration = array();
+class Logger implements SingletonInterface
+{
+    /**
+     * @var array Devlog extension configuration
+     */
+    protected $extensionConfiguration = array();
 
-       /**
-        * @var array List of instances of each available log writer
-        */
-       protected $logWriters = array();
+    /**
+     * @var array List of instances of each available log writer
+     */
+    protected $logWriters = array();
 
-       /**
-        * @var bool Flag used to turn logging off
-        */
-       protected $isLoggingEnabled = TRUE;
+    /**
+     * @var bool Flag used to turn logging off
+     */
+    protected $isLoggingEnabled = TRUE;
 
-       /**
-        * @var string Unique ID of the current run
-        */
-       protected $runId;
+    /**
+     * @var string Unique ID of the current run
+     */
+    protected $runId;
 
-       /**
-        * @var int Counter for entries within the current run
-        */
-       protected $counter = 0;
+    /**
+     * @var int Counter for entries within the current run
+     */
+    protected $counter = 0;
 
-       public function __construct() {
-               // Read the extension configuration
-               $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['devlog']);
+    public function __construct()
+    {
+        // Read the extension configuration
+        $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['devlog']);
 
-               // Use microtime as unique ID (in format "sec.msec")
-               $microtimeParts = explode(' ', microtime());
-               $this->runId = $microtimeParts[1] . $microtimeParts[0];
+        // Use microtime as unique ID (in format "sec.msec")
+        $microtimeParts = explode(' ', microtime());
+        $this->runId = $microtimeParts[1] . $microtimeParts[0];
 
-               // Create a list of instances of each available log writer
-               foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers'] as $logWriterClass) {
-                       try {
-                               $logWriter = GeneralUtility::makeInstance(
-                                       $logWriterClass,
-                                       $this
-                               );
-                               if ($logWriter instanceof WriterInterface) {
-                                       $this->logWriters[] = $logWriter;
-                               }
-                       }
-                       catch (\Exception $e) {
-                               // TODO: report somewhere that writer could not be instantiated (sys_log?)
-                       }
-               }
-       }
+        // Create a list of instances of each available log writer
+        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers'] as $logWriterClass) {
+            try {
+                $logWriter = GeneralUtility::makeInstance(
+                    $logWriterClass,
+                    $this
+                );
+                if ($logWriter instanceof WriterInterface) {
+                    $this->logWriters[] = $logWriter;
+                }
+            }
+            catch (\Exception $e) {
+                // TODO: report somewhere that writer could not be instantiated (sys_log?)
+            }
+        }
+    }
 
-       /**
-        * Logs calls passed to \TYPO3\CMS\Core\Utility\GeneralUtility::devLog().
-        *
-        * $logData = array('msg'=>$msg, 'extKey'=>$extKey, 'severity'=>$severity, 'dataVar'=>$dataVar);
-        *              'msg'           string          Message (in english).
-        *              'extKey'        string          Extension key (from which extension you are calling the log)
-        *              'severity'      integer         Severity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
-        *              'dataVar'       array           Additional data you want to pass to the logger.
-        *
-        * @param array $logData Log data
-        * @return void
-        */
-       public function log($logData) {
-               // If logging is disabled, abort immediately
-               if (!$this->isLoggingEnabled) {
-                       return;
-               }
-               // Add IP address for validation
-               $logData['ip'] = GeneralUtility::getIndpEnv('REMOTE_ADDR');
-               // If the log entry doesn't pass the basic filters, exit early doing nothing
-               if (!$this->isEntryAccepted($logData)) {
-                       return;
-               }
-               // Disable logging while inside the devlog, to avoid recursive calls
-               $this->isLoggingEnabled = FALSE;
+    /**
+     * Logs calls passed to \TYPO3\CMS\Core\Utility\GeneralUtility::devLog().
+     *
+     * $logData = array('msg'=>$msg, 'extKey'=>$extKey, 'severity'=>$severity, 'dataVar'=>$dataVar);
+     *         'msg'           string          Message (in english).
+     *         'extKey'        string          Extension key (from which extension you are calling the log)
+     *         'severity'      integer         Severity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
+     *         'dataVar'       array           Additional data you want to pass to the logger.
+     *
+     * @param array $logData Log data
+     * @return void
+     */
+    public function log($logData)
+    {
+        // If logging is disabled, abort immediately
+        if (!$this->isLoggingEnabled) {
+            return;
+        }
+        // Add IP address for validation
+        $logData['ip'] = GeneralUtility::getIndpEnv('REMOTE_ADDR');
+        // If the log entry doesn't pass the basic filters, exit early doing nothing
+        if (!$this->isEntryAccepted($logData)) {
+            return;
+        }
+        // Disable logging while inside the devlog, to avoid recursive calls
+        $this->isLoggingEnabled = FALSE;
 
-               // Create an entry and fill it with data
-               /** @var \Devlog\Devlog\Domain\Model\Entry $entry */
-               $entry = GeneralUtility::makeInstance('Devlog\\Devlog\\Domain\\Model\\Entry');
-               $entry->setRunId(
-                       $this->runId
-               );
-               $entry->setSorting(
-                       $this->counter
-               );
-               $this->counter++;
-               $entry->setCrdate($GLOBALS['EXEC_TIME']);
-               $entry->setMessage(
-                       GeneralUtility::removeXSS($logData['msg'])
-               );
-               $entry->setExtkey(
-                       strip_tags($logData['extKey'])
-               );
-               $entry->setSeverity(
-                       intval($logData['severity'])
-               );
-               $entry->setExtraData($logData['dataVar']);
+        // Create an entry and fill it with data
+        /** @var \Devlog\Devlog\Domain\Model\Entry $entry */
+        $entry = GeneralUtility::makeInstance('Devlog\\Devlog\\Domain\\Model\\Entry');
+        $entry->setRunId(
+            $this->runId
+        );
+        $entry->setSorting(
+            $this->counter
+        );
+        $this->counter++;
+        $entry->setCrdate($GLOBALS['EXEC_TIME']);
+        $entry->setMessage(
+            GeneralUtility::removeXSS($logData['msg'])
+        );
+        $entry->setExtkey(
+            strip_tags($logData['extKey'])
+        );
+        $entry->setSeverity(
+            intval($logData['severity'])
+        );
+        $entry->setExtraData($logData['dataVar']);
 
-               // Try to get a page id that makes sense
-               $pid = 0;
-               // In the FE context, this is obviously the current page
-               if (TYPO3_MODE == 'FE') {
-                       $pid = $GLOBALS['TSFE']->id;
+        // Try to get a page id that makes sense
+        $pid = 0;
+        // In the FE context, this is obviously the current page
+        if (TYPO3_MODE == 'FE') {
+            $pid = $GLOBALS['TSFE']->id;
 
-               // In other contexts, a global variable may be set with a relevant pid
-               } elseif (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['debugData']['pid'])) {
-                       $pid = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['debugData']['pid'];
-               }
-               $entry->setPid($pid);
+        // In other contexts, a global variable may be set with a relevant pid
+        } elseif (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['debugData']['pid'])) {
+            $pid = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['debugData']['pid'];
+        }
+        $entry->setPid($pid);
 
-               $entry->setCruserId(
-                       (isset($GLOBALS['BE_USER']->user['uid'])) ? $GLOBALS['BE_USER']->user['uid'] : 0
-               );
-               $entry->setIp(
-                       $logData['ip']
-               );
+        $entry->setCruserId(
+            (isset($GLOBALS['BE_USER']->user['uid'])) ? $GLOBALS['BE_USER']->user['uid'] : 0
+        );
+        $entry->setIp(
+            $logData['ip']
+        );
 
-               // Get information about the place where this method was called from
-               try {
-                       $callPlaceInfo = $this->getCallPlaceInfo(debug_backtrace());
-                       $entry->setLocation($callPlaceInfo['basename']);
-                       $entry->setLine($callPlaceInfo['line']);
-               }
-               catch (\OutOfBoundsException $e) {
-                       // Do nothing
-               }
+        // Get information about the place where this method was called from
+        try {
+            $callPlaceInfo = $this->getCallPlaceInfo(debug_backtrace());
+            $entry->setLocation($callPlaceInfo['basename']);
+            $entry->setLine($callPlaceInfo['line']);
+        }
+        catch (\OutOfBoundsException $e) {
+            // Do nothing
+        }
 
-               // Loop on all writers to output the log entry to some backend
-               /** @var \Devlog\Devlog\Writer\WriterInterface $logWriter */
-               foreach ($this->logWriters as $logWriter) {
-                       $logWriter->write($entry);
-               }
-               $this->isLoggingEnabled = TRUE;
-       }
+        // Loop on all writers to output the log entry to some backend
+        /** @var \Devlog\Devlog\Writer\WriterInterface $logWriter */
+        foreach ($this->logWriters as $logWriter) {
+            $logWriter->write($entry);
+        }
+        $this->isLoggingEnabled = TRUE;
+    }
 
-       /**
-        * Checks whether the given log data passes the filters or not.
-        *
-        * @param array $logData Log information
-        * @return bool
-        */
-       public function isEntryAccepted($logData) {
-               // Skip entry if severity is below minimum level
-               if ($logData['severity'] < $this->extensionConfiguration['minimumLogLevel']) {
-                       return FALSE;
-               }
-               // Skip entry if key is in excluded list
-               if (GeneralUtility::inList($this->extensionConfiguration['excludeKeys'], $logData['extKey'])) {
-                       return FALSE;
-               }
-               // Skip entry if referrer does not match IP mask
-               if (!$this->isIpAddressAccepted($logData['ip'])) {
-                       return FALSE;
-               }
-               return TRUE;
-       }
+    /**
+     * Checks whether the given log data passes the filters or not.
+     *
+     * @param array $logData Log information
+     * @return bool
+     */
+    public function isEntryAccepted($logData)
+    {
+        // Skip entry if severity is below minimum level
+        if ($logData['severity'] < $this->extensionConfiguration['minimumLogLevel']) {
+            return FALSE;
+        }
+        // Skip entry if key is in excluded list
+        if (GeneralUtility::inList($this->extensionConfiguration['excludeKeys'], $logData['extKey'])) {
+            return FALSE;
+        }
+        // Skip entry if referrer does not match IP mask
+        if (!$this->isIpAddressAccepted($logData['ip'])) {
+            return FALSE;
+        }
+        return TRUE;
+    }
 
-       /**
-        * Checks if given IP address is acceptable.
-        *
-        * @param string $ipAddress IP address to check
-        * @return bool
-        */
-       public function isIpAddressAccepted($ipAddress) {
-               $ipFilter = $this->extensionConfiguration['ipFilter'];
-               // Re-use global IP mask if so defined
-               if (strtolower($ipFilter) === 'devipmask') {
-                       $ipFilter = $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'];
-               }
-               return GeneralUtility::cmpIP($ipAddress, $ipFilter);
-       }
+    /**
+     * Checks if given IP address is acceptable.
+     *
+     * @param string $ipAddress IP address to check
+     * @return bool
+     */
+    public function isIpAddressAccepted($ipAddress)
+    {
+        $ipFilter = $this->extensionConfiguration['ipFilter'];
+        // Re-use global IP mask if so defined
+        if (strtolower($ipFilter) === 'devipmask') {
+            $ipFilter = $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'];
+        }
+        return GeneralUtility::cmpIP($ipAddress, $ipFilter);
+    }
 
-       /**
-        * Given a backtrace, this method tries to find the place where a "devLog" function was called
-        * and returns info about that place.
-        *
-        * @return      array   information about the call place
-        */
-       protected function getCallPlaceInfo() {
-               $backTrace = debug_backtrace();
-               foreach ($backTrace as $entry) {
-                       if ($entry['function'] === 'devLog') {
-                               $pathInfo = pathinfo($entry['file']);
-                               $pathInfo['line'] = $entry['line'];
-                               return $pathInfo;
-                       }
-               }
-               throw new \OutOfBoundsException(
-                       'No devLog() call found withing debug stack.',
-                       1414338781
-               );
-       }
+    /**
+     * Given a backtrace, this method tries to find the place where a "devLog" function was called
+     * and returns info about that place.
+     *
+     * @return array   information about the call place
+     */
+    protected function getCallPlaceInfo()
+    {
+        $backTrace = debug_backtrace();
+        foreach ($backTrace as $entry) {
+            if ($entry['function'] === 'devLog') {
+                $pathInfo = pathinfo($entry['file']);
+                $pathInfo['line'] = $entry['line'];
+                return $pathInfo;
+            }
+        }
+        throw new \OutOfBoundsException(
+            'No devLog() call found withing debug stack.',
+            1414338781
+        );
+    }
 
-       /**
-        * Returns the extension's configuration.
-        *
-        * @return array
-        */
-       public function getExtensionConfiguration() {
-               return $this->extensionConfiguration;
-       }
+    /**
+     * Returns the extension's configuration.
+     *
+     * @return array
+     */
+    public function getExtensionConfiguration()
+    {
+        return $this->extensionConfiguration;
+    }
 
-       /**
-        * Sets the extension configuration.
-        *
-        * This should normally not be used. It is designed for unit testing.
-        *
-        * @param array $extensionConfiguration
-        * @return void
-        */
-       public function setExtensionConfiguration($extensionConfiguration) {
-               $this->extensionConfiguration = $extensionConfiguration;
-       }
+    /**
+     * Sets the extension configuration.
+     *
+     * This should normally not be used. It is designed for unit testing.
+     *
+     * @param array $extensionConfiguration
+     * @return void
+     */
+    public function setExtensionConfiguration($extensionConfiguration)
+    {
+        $this->extensionConfiguration = $extensionConfiguration;
+    }
 
-       /**
-        * Returns the logging enabled flag.
-        *
-        * @return bool
-        */
-       public function isLoggingEnabled() {
-               return $this->isLoggingEnabled;
-       }
+    /**
+     * Returns the logging enabled flag.
+     *
+     * @return bool
+     */
+    public function isLoggingEnabled()
+    {
+        return $this->isLoggingEnabled;
+    }
 
-       /**
-        * Sets the logging enabled flag.
-        *
-        * @param bool $flag
-        * @return void
-        */
-       public function setIsLoggingEnabled($flag) {
-               $this->isLoggingEnabled = (bool)$flag;
-       }
+    /**
+     * Sets the logging enabled flag.
+     *
+     * @param bool $flag
+     * @return void
+     */
+    public function setIsLoggingEnabled($flag)
+    {
+        $this->isLoggingEnabled = (bool)$flag;
+    }
 }
\ No newline at end of file
index 550a86f..a713b71 100644 (file)
@@ -19,78 +19,85 @@ use TYPO3\CMS\Backend\Utility\IconUtility;
 /**
  * TCEforms custom field for devlog table.
  */
-class TceForms {
+class TceForms
+{
 
-       protected $extKey = 'devlog';
+    /**
+     * @var string
+     */
+    protected $extKey = 'devlog';
 
-       /**
-        * Returns the severity of the entry using TYPO3's icon and labels
-        *
-        * @param array $PA Information related to the field
-        * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
-        *
-        * @return string The HTML for the form field
-        */
-       public function displaySeverity($PA, $formObject) {
-               // Translate severity to icon "name"
-               $severity = $PA['row']['severity'];
-               switch ($severity) {
-                       case -1:
-                               $severityName = 'ok';
-                               break;
-                       case 1:
-                               $severityName = 'notification';
-                               break;
-                       case 2:
-                               $severityName = 'warning';
-                               break;
-                       case 3:
-                               $severityName = 'error';
-                               break;
-                       default:
-                               $severityName = 'information';
-               }
+    /**
+     * Returns the severity of the entry using TYPO3's icon and labels
+     *
+     * @param array $PA Information related to the field
+     * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
+     *
+     * @return string The HTML for the form field
+     */
+    public function displaySeverity($PA, $formObject)
+    {
+        // Translate severity to icon "name"
+        $severity = $PA['row']['severity'];
+        switch ($severity) {
+            case -1:
+                $severityName = 'ok';
+                break;
+            case 1:
+                $severityName = 'notification';
+                break;
+            case 2:
+                $severityName = 'warning';
+                break;
+            case 3:
+                $severityName = 'error';
+                break;
+            default:
+                $severityName = 'information';
+        }
 
-               $html = IconUtility::getSpriteIcon(
-                       'status-dialog-' . $severityName,
-                       array(
-                               'title' => $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:severity_' . $severityName)
-                       )
-               );
-               return $html;
-       }
+        $html = IconUtility::getSpriteIcon(
+            'status-dialog-' . $severityName,
+            array(
+                'title' => $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:severity_' . $severityName)
+            )
+        );
+        return $html;
+    }
 
-       /**
-        * Returns the extra data as a nice HTML dump.
-        *
-        * @param array $PA Information related to the field
-        * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
-        *
-        * @return string The HTML for the form field
-        */
-       public function displayExtraData($PA, $formObject) {
-               if (empty($PA['row']['extra_data'])) {
-                       $html = $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:no_extra_data');
-               } else {
-                       $data = unserialize(gzuncompress($PA['row']['extra_data']));
-                       $html = \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
-                               $data,
-                               NULL,
-                               10,
-                               FALSE,
-                               TRUE,
-                               TRUE
-                       );
-               }
-               return $html;
-       }
+    /**
+     * Returns the extra data as a nice HTML dump.
+     *
+     * @param array $PA Information related to the field
+     * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
+     *
+     * @return string The HTML for the form field
+     */
+    public function displayExtraData($PA, $formObject)
+    {
+        if (empty($PA['row']['extra_data'])) {
+            $html = $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:no_extra_data');
+        } else {
+            $data = unserialize(gzuncompress($PA['row']['extra_data']));
+            $html = \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
+                $data,
+                NULL,
+                10,
+                FALSE,
+                TRUE,
+                TRUE
+            );
+        }
+        return $html;
+    }
 
-       /**
-        * Wrapper around the global language object.
-        *
-        * @return \TYPO3\CMS\Lang\LanguageService
-        */
-       protected function getLanguageObject() {
-               return $GLOBALS['LANG'];
-       }
+    /**
+     * Wrapper around the global language object.
+     *
+     * @return \TYPO3\CMS\Lang\LanguageService
+     */
+    protected function getLanguageObject()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index 4982984..6dc13c1 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 namespace Devlog\Devlog\Writer;
 
-
 /***************************************************************
  *
  *  Copyright notice
@@ -30,18 +29,20 @@ namespace Devlog\Devlog\Writer;
 /**
  * Abstract base class for all Writers.
  */
-abstract class AbstractWriter implements WriterInterface {
-       /**
-        * @var \Devlog\Devlog\Utility\Logger Back-reference to the logger class
-        */
-       protected $logger;
+abstract class AbstractWriter implements WriterInterface
+{
+    /**
+     * @var \Devlog\Devlog\Utility\Logger Back-reference to the logger class
+     */
+    protected $logger;
 
-       /**
-        * Base constructor sets the Logger reference.
-        *
-        * @param \Devlog\Devlog\Utility\Logger $logger
-        */
-       public function __construct($logger) {
-               $this->logger = $logger;
-       }
+    /**
+     * Base constructor sets the Logger reference.
+     *
+     * @param \Devlog\Devlog\Utility\Logger $logger
+     */
+    public function __construct($logger)
+    {
+        $this->logger = $logger;
+    }
 }
\ No newline at end of file
index e900354..77a5a6a 100644 (file)
@@ -30,28 +30,36 @@ namespace Devlog\Devlog\Writer;
 /**
  * Writes log entries to a database table.
  */
-class DatabaseWriter extends AbstractWriter {
-       /**
-        * @var \Devlog\Devlog\Domain\Repository\EntryRepository
-        */
-       protected $entryRepository;
+class DatabaseWriter extends AbstractWriter
+{
+    /**
+     * @var \Devlog\Devlog\Domain\Repository\EntryRepository
+     */
+    protected $entryRepository;
 
-       public function __construct($logger) {
-               parent::__construct($logger);
-               $this->entryRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Devlog\\Devlog\\Domain\\Repository\\EntryRepository');
-               $this->entryRepository->setExtensionConfiguration(
-                       $this->logger->getExtensionConfiguration()
-               );
-       }
+    /**
+     * DatabaseWriter constructor.
+     *
+     * @param \Devlog\Devlog\Utility\Logger $logger
+     */
+    public function __construct($logger)
+    {
+        parent::__construct($logger);
+        $this->entryRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Devlog\\Devlog\\Domain\\Repository\\EntryRepository');
+        $this->entryRepository->setExtensionConfiguration(
+            $this->logger->getExtensionConfiguration()
+        );
+    }
 
-       /**
-        * Writes the entry to the DB storage.
-        *
-        * @param \Devlog\Devlog\Domain\Model\Entry $entry
-        * @return void
-        */
-       public function write($entry) {
-               $this->entryRepository->add($entry);
-               $this->entryRepository->cleanUp();
-       }
+    /**
+     * Writes the entry to the DB storage.
+     *
+     * @param \Devlog\Devlog\Domain\Model\Entry $entry
+     * @return void
+     */
+    public function write($entry)
+    {
+        $this->entryRepository->add($entry);
+        $this->entryRepository->cleanUp();
+    }
 }
\ No newline at end of file
index 6696ed5..76f9413 100644 (file)
@@ -31,83 +31,97 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * Writes log entries to a given file
  */
-class FileWriter extends AbstractWriter {
-       /**
-        * Handle to the log file.
-        *
-        * @var resource
-        */
-       protected $fileHandle;
+class FileWriter extends AbstractWriter
+{
+    /**
+     * Handle to the log file.
+     *
+     * @var resource
+     */
+    protected $fileHandle;
 
-       public function __construct($logger) {
-               parent::__construct($logger);
-               $configuration = $this->logger->getExtensionConfiguration();
-               $absoluteFilePath = GeneralUtility::getFileAbsFileName(
-                       $configuration['logFilePath']
-               );
-               // If the file path is not valid, throw an exception
-               if (empty($absoluteFilePath)) {
-                       throw new \Exception(
-                               sprintf(
-                                       'Path to log file %s is invalid.',
-                                       $configuration['logFilePath']
-                               ),
-                               1416486859
-                       );
-               }
-               // If the file path is valid, try opening the file
-               $this->fileHandle = @fopen(
-                       $absoluteFilePath,
-                       'a'
-               );
-               // Throw an exception if log file could not be opened properly
-               if (!$this->fileHandle) {
-                       throw new \Exception(
-                               sprintf(
-                                       'Log file %s could not be opened.',
-                                       $configuration['logFilePath']
-                               ),
-                               1416486470
-                       );
-               }
-       }
+    /**
+     * FileWriter constructor.
+     *
+     * @param \Devlog\Devlog\Utility\Logger $logger
+     *
+     * @throws \Exception
+     */
+    public function __construct($logger)
+    {
+        parent::__construct($logger);
+        $configuration = $this->logger->getExtensionConfiguration();
+        $absoluteFilePath = GeneralUtility::getFileAbsFileName(
+            $configuration['logFilePath']
+        );
+        // If the file path is not valid, throw an exception
+        if (empty($absoluteFilePath)) {
+            throw new \Exception(
+                sprintf(
+                    'Path to log file %s is invalid.',
+                    $configuration['logFilePath']
+                ),
+                1416486859
+            );
+        }
+        // If the file path is valid, try opening the file
+        $this->fileHandle = @fopen(
+            $absoluteFilePath,
+            'a'
+        );
+        // Throw an exception if log file could not be opened properly
+        if (!$this->fileHandle) {
+            throw new \Exception(
+                sprintf(
+                    'Log file %s could not be opened.',
+                    $configuration['logFilePath']
+                ),
+                1416486470
+            );
+        }
+    }
 
-       public function __destruct() {
-               @fclose($this->fileHandle);
-       }
+    /**
+     * Destructor
+     */
+    public function __destruct()
+    {
+        @fclose($this->fileHandle);
+    }
 
-       /**
-        * Writes the entry to the log file.
-        *
-        * @param \Devlog\Devlog\Domain\Model\Entry $entry
-        * @return void
-        */
-       public function write($entry) {
-               $logLine = '';
-               $logLine .= date('c', $entry->getCrdate());
-               switch ($entry->getSeverity()) {
-                       case 0:
-                               $severity = 'INFO';
-                               break;
-                       case 1:
-                               $severity = 'NOTICE';
-                               break;
-                       case 2:
-                               $severity = 'WARNING';
-                               break;
-                       case 3:
-                               $severity = 'ERROR';
-                               break;
-                       default:
-                               $severity = 'OK';
-               }
-               $logLine .= ' [' . $severity . ']';
-               $logLine .= ' ' . $entry->getMessage();
-               $logLine .= ' (' . $entry->getLocation() . ' ' . $entry->getLine() . ')';
-               $logLine .= "\n";
-               @fwrite(
-                       $this->fileHandle,
-                       $logLine
-               );
-       }
+    /**
+     * Writes the entry to the log file.
+     *
+     * @param \Devlog\Devlog\Domain\Model\Entry $entry
+     * @return void
+     */
+    public function write($entry)
+    {
+        $logLine = '';
+        $logLine .= date('c', $entry->getCrdate());
+        switch ($entry->getSeverity()) {
+            case 0:
+                $severity = 'INFO';
+                break;
+            case 1:
+                $severity = 'NOTICE';
+                break;
+            case 2:
+                $severity = 'WARNING';
+                break;
+            case 3:
+                $severity = 'ERROR';
+                break;
+            default:
+                $severity = 'OK';
+        }
+        $logLine .= ' [' . $severity . ']';
+        $logLine .= ' ' . $entry->getMessage();
+        $logLine .= ' (' . $entry->getLocation() . ' ' . $entry->getLine() . ')';
+        $logLine .= "\n";
+        @fwrite(
+            $this->fileHandle,
+            $logLine
+        );
+    }
 }
\ No newline at end of file
index ddc45b6..e1419f3 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 namespace Devlog\Devlog\Writer;
 
-
 /***************************************************************
  *
  *  Copyright notice
@@ -30,12 +29,13 @@ namespace Devlog\Devlog\Writer;
 /**
  * API definition for log writers
  */
-interface WriterInterface {
-       /**
-        * Writes the entry to the relevant storage.
-        *
-        * @param \Devlog\Devlog\Domain\Model\Entry $entry
-        * @return mixed
-        */
-       public function write($entry);
+interface WriterInterface
+{
+    /**
+     * Writes the entry to the relevant storage.
+     *
+     * @param \Devlog\Devlog\Domain\Model\Entry $entry
+     * @return mixed
+     */
+    public function write($entry);
 }
\ No newline at end of file
index 20b9e18..62be9ad 100644 (file)
 <?php
 if (!defined ('TYPO3_MODE')) {
-       die ('Access denied.');
+    die ('Access denied.');
 }
 
 return array(
-       'ctrl' => array(
-               'title' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry',
-               'label' => 'message',
-               'tstamp' => 'tstamp',
-               'crdate' => 'crdate',
-               'cruser_id' => 'cruser_id',
-               'default_sortby' => 'ORDER BY crdate DESC, sorting ASC',
-               'dividers2tabs' => TRUE,
-               'searchFields' => 'severity,extkey,message,location,ip,line,extra_data',
-               'typeicon_column' => 'severity',
-               'typeicon_classes' => array(
-                       'default' => 'extensions-devlog-entry',
-                       '-1' => 'status-dialog-ok',
-                       '0' => 'status-dialog-information',
-                       '1' => 'status-dialog-notification',
-                       '2' => 'status-dialog-warning',
-                       '3' => 'status-dialog-error'
-               ),
-       ),
-       'interface' => array(
-               'showRecordFieldList' => 'severity, extkey, message, location, line, ip, extra_data',
-       ),
-       'types' => array(
-               '1' => array('showitem' => 'crdate, cruser_id, severity, extkey, message, location, line, ip, extra_data'),
-       ),
-       'columns' => array(
-               'crdate' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.crdate',
-                       'config' => array(
-                               'type' => 'input',
-                               'readOnly' => TRUE,
-                               'eval' => 'datetime'
-                       )
-               ),
-               'cruser_id' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.cruser_id',
-                       'config' => array(
-                               'type' => 'select',
-                               'readOnly' => TRUE,
-                               'items' => array(
-                                       array()
-                               ),
-                               'foreign_table' => 'be_users',
-                               'size' => 1
-                       )
-               ),
-               'severity' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.severity',
-                       'config' => array(
-                               'type' => 'user',
-                               'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displaySeverity',
-                       )
-               ),
-               'extkey' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extkey',
-                       'config' => array(
-                               'type' => 'input',
-                               'readOnly' => TRUE,
-                               'size' => 30,
-                               'eval' => 'trim'
-                       ),
-               ),
-               'message' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.message',
-                       'config' => array(
-                               'type' => 'text',
-                               'readOnly' => TRUE,
-                               'cols' => 50,
-                               'rows' => 5,
-                               'eval' => 'trim'
-                       )
-               ),
-               'location' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.location',
-                       'config' => array(
-                               'type' => 'input',
-                               'readOnly' => TRUE,
-                               'size' => 30,
-                               'eval' => 'trim'
-                       ),
-               ),
-               'line' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.line',
-                       'config' => array(
-                               'type' => 'input',
-                               'readOnly' => TRUE,
-                               'size' => 30,
-                               'eval' => 'trim'
-                       ),
-               ),
-               'ip' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.ip',
-                       'config' => array(
-                               'type' => 'input',
-                               'readOnly' => TRUE,
-                               'size' => 30,
-                               'eval' => 'trim'
-                       ),
-               ),
-               'extra_data' => array(
-                       'exclude' => 0,
-                       'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extra_data',
-                       'config' => array(
-                               'type' => 'user',
-                               'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displayExtraData',
-                       )
-               ),
-       ),
+    'ctrl' => array(
+        'title'        => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry',
+        'label' => 'message',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'default_sortby' => 'ORDER BY crdate DESC, sorting ASC',
+        'dividers2tabs' => TRUE,
+        'searchFields' => 'severity,extkey,message,location,ip,line,extra_data',
+        'typeicon_column' => 'severity',
+        'typeicon_classes' => array(
+            'default' => 'extensions-devlog-entry',
+            '-1' => 'status-dialog-ok',
+            '0' => 'status-dialog-information',
+            '1' => 'status-dialog-notification',
+            '2' => 'status-dialog-warning',
+            '3' => 'status-dialog-error'
+        ),
+    ),
+    'interface' => array(
+        'showRecordFieldList' => 'severity, extkey, message, location, line, ip, extra_data',
+    ),
+    'types' => array(
+        '1' => array('showitem' => 'crdate, cruser_id, severity, extkey, message, location, line, ip, extra_data'),
+    ),
+    'columns' => array(
+        'crdate' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.crdate',
+            'config' => array(
+                'type' => 'input',
+                'readOnly' => TRUE,
+                'eval' => 'datetime'
+            )
+        ),
+        'cruser_id' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.cruser_id',
+            'config' => array(
+                'type' => 'select',
+                'readOnly' => TRUE,
+                'items' => array(
+                    array()
+                ),
+                'foreign_table' => 'be_users',
+                'size' => 1
+            )
+        ),
+        'severity' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.severity',
+            'config' => array(
+                'type' => 'user',
+                'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displaySeverity',
+            )
+        ),
+        'extkey' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extkey',
+            'config' => array(
+                'type' => 'input',
+                'readOnly' => TRUE,
+                'size' => 30,
+                'eval' => 'trim'
+            ),
+        ),
+        'message' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.message',
+            'config' => array(
+                'type' => 'text',
+                'readOnly' => TRUE,
+                'cols' => 50,
+                'rows' => 5,
+                'eval' => 'trim'
+            )
+        ),
+        'location' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.location',
+            'config' => array(
+                'type' => 'input',
+                'readOnly' => TRUE,
+                'size' => 30,
+                'eval' => 'trim'
+            ),
+        ),
+        'line' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.line',
+            'config' => array(
+                'type' => 'input',
+                'readOnly' => TRUE,
+                'size' => 30,
+                'eval' => 'trim'
+            ),
+        ),
+        'ip' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.ip',
+            'config' => array(
+                'type' => 'input',
+                'readOnly' => TRUE,
+                'size' => 30,
+                'eval' => 'trim'
+            ),
+        ),
+        'extra_data' => array(
+            'exclude' => 0,
+            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extra_data',
+            'config' => array(
+                'type' => 'user',
+                'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displayExtraData',
+            )
+        ),
+    ),
 );
index 49f327e..526621a 100644 (file)
@@ -22,316 +22,343 @@ use Devlog\Devlog\Domain\Model\Entry;
  *
  * @author Fran├žois Suter <typo3@cobweb.ch>
  */
-class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-       /**
-        * @var Entry
-        */
-       protected $subject = NULL;
-
-       protected function setUp() {
-               $this->subject = new Entry();
-       }
-
-       protected function tearDown() {
-               unset($this->subject);
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getRunId
-        */
-       public function getRunIdReturnsInitialValueForString() {
-               $this->assertSame(
-                       '',
-                       $this->subject->getRunId()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setRunId
-        */
-       public function setRunIdForStringSetsExtkey() {
-               $this->subject->setRunId('12345678987.65432100');
-
-               $this->assertAttributeEquals(
-                       '12345678987.65432100',
-                       'runId',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getSorting
-        */
-       public function getSortingReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getSorting()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setSorting
-        */
-       public function setSortingForIntegerSetsSorting() {
-               $this->subject->setSorting(12);
-
-               $this->assertAttributeEquals(
-                       12,
-                       'sorting',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getCrdate
-        */
-       public function getCrdateReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getCrdate()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setCrdate
-        */
-       public function setCrdateForIntegerSetsSeverity() {
-               $this->subject->setCrdate(1417705263);
-
-               $this->assertAttributeEquals(
-                       1417705263,
-                       'crdate',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getSeverity
-        */
-       public function getSeverityReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getSeverity()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setSeverity
-        */
-       public function setSeverityForIntegerSetsSeverity() {
-               $this->subject->setSeverity(2);
-
-               $this->assertAttributeEquals(
-                       2,
-                       'severity',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getExtkey
-        */
-       public function getExtkeyReturnsInitialValueForString() {
-               $this->assertSame(
-                       '',
-                       $this->subject->getExtkey()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setExtkey
-        */
-       public function setExtkeyForStringSetsExtkey() {
-               $this->subject->setExtkey('devlog');
-
-               $this->assertAttributeEquals(
-                       'devlog',
-                       'extkey',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getMessage
-        */
-       public function getMessageReturnsInitialValueForString() {
-               $this->assertSame(
-                       '',
-                       $this->subject->getMessage()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setMessage
-        */
-       public function setMessageForStringSetsMessage() {
-               $this->subject->setMessage('This is a message');
-
-               $this->assertAttributeEquals(
-                       'This is a message',
-                       'message',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getLocation
-        */
-       public function getLocationReturnsInitialValueForString() {
-               $this->assertSame(
-                       '',
-                       $this->subject->getLocation()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setLocation
-        */
-       public function setLocationForStringSetsLocation() {
-               $this->subject->setLocation('Entry.php');
-
-               $this->assertAttributeEquals(
-                       'Entry.php',
-                       'location',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getLine
-        */
-       public function getLineReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getLine()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setLine
-        */
-       public function setLineForIntegerSetsLine() {
-               $this->subject->setLine(42);
-
-               $this->assertAttributeEquals(
-                       42,
-                       'line',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getIp
-        */
-       public function getIpReturnsInitialValueForString() {
-               $this->assertSame(
-                       '',
-                       $this->subject->getIp()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setIp
-        */
-       public function setIpForStringSetsIp() {
-               $this->subject->setIp('127.0.0.1');
-
-               $this->assertAttributeEquals(
-                       '127.0.0.1',
-                       'ip',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getCruserId
-        */
-       public function getCruserIdReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getCruserId()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setCruserId
-        */
-       public function setCruserIdForIntegerSetsSeverity() {
-               $this->subject->setCruserId(5);
-
-               $this->assertAttributeEquals(
-                       5,
-                       'cruserId',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getPid
-        */
-       public function getPidReturnsInitialValueForInteger() {
-               $this->assertSame(
-                       0,
-                       $this->subject->getPid()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setPid
-        */
-       public function setPidForIntegerSetsSeverity() {
-               $this->subject->setPid(17);
-
-               $this->assertAttributeEquals(
-                       17,
-                       'pid',
-                       $this->subject
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::getExtraData
-        */
-       public function getExtraDataReturnsInitialValueForString() {
-               $this->assertNull(
-                       $this->subject->getExtraData()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Domain\Model\Entry::setExtraData
-        */
-       public function setExtraDataForStringSetsExtraData() {
-               $this->subject->setExtraData('SomeBlob');
-
-               $this->assertAttributeEquals(
-                       'SomeBlob',
-                       'extraData',
-                       $this->subject
-               );
-       }
+class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
+{
+    /**
+     * @var Entry
+     */
+    protected $subject = NULL;
+
+    protected function setUp()
+    {
+        $this->subject = new Entry();
+    }
+
+    protected function tearDown()
+    {
+        unset($this->subject);
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getRunId
+     */
+    public function getRunIdReturnsInitialValueForString()
+    {
+        $this->assertSame(
+            '',
+            $this->subject->getRunId()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setRunId
+     */
+    public function setRunIdForStringSetsExtkey()
+    {
+        $this->subject->setRunId('12345678987.65432100');
+
+        $this->assertAttributeEquals(
+            '12345678987.65432100',
+            'runId',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getSorting
+     */
+    public function getSortingReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getSorting()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setSorting
+     */
+    public function setSortingForIntegerSetsSorting()
+    {
+        $this->subject->setSorting(12);
+
+        $this->assertAttributeEquals(
+            12,
+            'sorting',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getCrdate
+     */
+    public function getCrdateReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getCrdate()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setCrdate
+     */
+    public function setCrdateForIntegerSetsSeverity()
+    {
+        $this->subject->setCrdate(1417705263);
+
+        $this->assertAttributeEquals(
+            1417705263,
+            'crdate',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getSeverity
+     */
+    public function getSeverityReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getSeverity()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setSeverity
+     */
+    public function setSeverityForIntegerSetsSeverity()
+    {
+        $this->subject->setSeverity(2);
+
+        $this->assertAttributeEquals(
+            2,
+            'severity',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getExtkey
+     */
+    public function getExtkeyReturnsInitialValueForString()
+    {
+        $this->assertSame(
+            '',
+            $this->subject->getExtkey()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setExtkey
+     */
+    public function setExtkeyForStringSetsExtkey()
+    {
+        $this->subject->setExtkey('devlog');
+
+        $this->assertAttributeEquals(
+            'devlog',
+            'extkey',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getMessage
+     */
+    public function getMessageReturnsInitialValueForString()
+    {
+        $this->assertSame(
+            '',
+            $this->subject->getMessage()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setMessage
+     */
+    public function setMessageForStringSetsMessage()
+    {
+        $this->subject->setMessage('This is a message');
+
+        $this->assertAttributeEquals(
+            'This is a message',
+            'message',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getLocation
+     */
+    public function getLocationReturnsInitialValueForString()
+    {
+        $this->assertSame(
+            '',
+            $this->subject->getLocation()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setLocation
+     */
+    public function setLocationForStringSetsLocation()
+    {
+        $this->subject->setLocation('Entry.php');
+
+        $this->assertAttributeEquals(
+            'Entry.php',
+            'location',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getLine
+     */
+    public function getLineReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getLine()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setLine
+     */
+    public function setLineForIntegerSetsLine()
+    {
+        $this->subject->setLine(42);
+
+        $this->assertAttributeEquals(
+            42,
+            'line',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getIp
+     */
+    public function getIpReturnsInitialValueForString()
+    {
+        $this->assertSame(
+            '',
+            $this->subject->getIp()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setIp
+     */
+    public function setIpForStringSetsIp()
+    {
+        $this->subject->setIp('127.0.0.1');
+
+        $this->assertAttributeEquals(
+            '127.0.0.1',
+            'ip',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getCruserId
+     */
+    public function getCruserIdReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getCruserId()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setCruserId
+     */
+    public function setCruserIdForIntegerSetsSeverity()
+    {
+        $this->subject->setCruserId(5);
+
+        $this->assertAttributeEquals(
+            5,
+            'cruserId',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getPid
+     */
+    public function getPidReturnsInitialValueForInteger()
+    {
+        $this->assertSame(
+            0,
+            $this->subject->getPid()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setPid
+     */
+    public function setPidForIntegerSetsSeverity()
+    {
+        $this->subject->setPid(17);
+
+        $this->assertAttributeEquals(
+            17,
+            'pid',
+            $this->subject
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::getExtraData
+     */
+    public function getExtraDataReturnsInitialValueForString()
+    {
+        $this->assertNull(
+            $this->subject->getExtraData()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Domain\Model\Entry::setExtraData
+     */
+    public function setExtraDataForStringSetsExtraData()
+    {
+        $this->subject->setExtraData('SomeBlob');
+
+        $this->assertAttributeEquals(
+            'SomeBlob',
+            'extraData',
+            $this->subject
+        );
+    }
 }
index de1d128..849495a 100644 (file)
@@ -21,201 +21,218 @@ use Devlog\Devlog\Utility\Logger;
  *
  * @author Fran├žois Suter <typo3@cobweb.ch>
  */
-class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-       /**
-        * @var Logger
-        */
-       protected $subject = NULL;
-
-       /**
-        * @var array Test extension configuration
-        */
-       protected $testConfiguration = array(
-               'minimumLogLevel' => 1,
-               'excludeKeys' => 'foo,bar',
-               'ipFilter' => '127.0.0.1,::1'
-       );
-
-       protected function setUp() {
-               $this->subject = new Logger();
-               $this->subject->setExtensionConfiguration(
-                       $this->testConfiguration
-               );
-       }
-
-       protected function tearDown() {
-               unset($this->subject);
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Utility\Logger::isEntryAccepted
-        */
-       public function entryIsAccepted() {
-               $this->assertTrue(
-                       $this->subject->isEntryAccepted(
-                               array(
-                                       'severity' => 2,
-                                       'extKey' => 'whatever',
-                                       'ip' => '127.0.0.1'
-                               )
-                       )
-               );
-       }
-
-       public function validEntriesProvider() {
-               return array(
-                       'Severity too low' => array(
-                               array(
-                                       'severity' => 0,
-                                       'extKey' => 'whatever',
-                                       'ip' => '127.0.0.1'
-                               )
-                       ),
-                       'Excluded extension key' => array(
-                               array(
-                                       'severity' => 3,
-                                       'extKey' => 'foo',
-                                       'ip' => '127.0.0.1'
-                               )
-                       ),
-                       'IP does not match' => array(
-                               array(
-                                       'severity' => 3,
-                                       'extKey' => 'whatever',
-                                       'ip' => '192.168.1.1'
-                               )
-                       )
-               );
-       }
-
-       /**
-        * @param array $entry Log entry data
-        * @test
-        * @dataProvider validEntriesProvider
-        * @covers \Devlog\Devlog\Utility\Logger::isEntryAccepted
-        */
-       public function entryIsRefused($entry) {
-               $this->assertFalse(
-                       $this->subject->isEntryAccepted(
-                               $entry
-                       )
-               );
-       }
-
-       public function ipAddressesProvider() {
-               return array(
-                       'Valid IP v4' => array(
-                               '127.0.0.1',
-                               '',
-                               '',
-                               TRUE
-                       ),
-                       'Valid IP v6' => array(
-                               '::1',
-                               '',
-                               '',
-                               TRUE
-                       ),
-                       'Valid with devIPMask' => array(
-                               '192.168.1.67',
-                               'devIPMask',
-                               '192.168.1.*',
-                               TRUE
-                       ),
-                       'IP v4' => array(
-                               '192.168.1.1',
-                               '',
-                               '',
-                               FALSE
-                       ),
-                       'IP v6' => array(
-                               '2001:db8::ff00:42:8329',
-                               '',
-                               '',
-                               FALSE
-                       ),
-                       'devIPMask' => array(
-                               '80.58.212.14',
-                               'devIPMask',
-                               '192.168.1.*',
-                               FALSE
-                       )
-               );
-       }
-
-       /**
-        * @param string $testValue IP address to test
-        * @param string $configurationOverride Override IP filter in extension configuration
-        * @param string $devIpMask Value for overriding $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
-        * @param boolean $result TRUE or FALSE, depending on IP address validity
-        * @test
-        * @dataProvider ipAddressesProvider
-        * @covers \Devlog\Devlog\Utility\Logger::isIpAddressAccepted
-        */
-       public function isIpAddressValid($testValue, $configurationOverride, $devIpMask, $result) {
-               $savedIpMask = $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'];
-               // Override devIPmask
-               if (!empty($devIpMask)) {
-                       $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $devIpMask;
-               }
-               // Override extension configuration
-               if (!empty($configurationOverride)) {
-                       $specialConfiguration = $this->testConfiguration;
-                       $specialConfiguration['ipFilter'] = $configurationOverride;
-                       $this->subject->setExtensionConfiguration(
-                               $specialConfiguration
-                       );
-               }
-               // Perform the actual test
-               $this->assertSame(
-                       $result,
-                       $this->subject->isIpAddressAccepted(
-                               $testValue
-                       )
-               );
-               // Restore extension configuration
-               $this->subject->setExtensionConfiguration(
-                       $this->testConfiguration
-               );
-               // Restore devIPmask
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $savedIpMask;
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Utility\Logger::getExtensionConfiguration
-        * @covers \Devlog\Devlog\Utility\Logger::setExtensionConfiguration
-        */
-       public function getConfigurationReturnsTestValue() {
-               $this->assertSame(
-                       $this->subject->getExtensionConfiguration(),
-                       $this->testConfiguration
-               );
-       }
-
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Utility\Logger::isLoggingEnabled
-        */
-       public function getIsLoggingEnabledReturnsInitialValueForBoolean() {
-               $this->assertTrue(
-                       $this->subject->isLoggingEnabled()
-               );
-       }
-
-       /**
-        * @test
-        * @covers \Devlog\Devlog\Utility\Logger::setIsLoggingEnabled
-        */
-       public function setIsLoggingEnabledForBooleanSetsIsLoggingEnabled() {
-               $this->subject->setIsLoggingEnabled(FALSE);
-
-               $this->assertAttributeEquals(
-                       FALSE,
-                       'isLoggingEnabled',
-                       $this->subject
-               );
-       }
+class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
+{
+    /**
+     * @var Logger
+     */
+    protected $subject = NULL;
+
+    /**
+     * @var array Test extension configuration
+     */
+    protected $testConfiguration = array(
+        'minimumLogLevel' => 1,
+        'excludeKeys' => 'foo,bar',
+        'ipFilter' => '127.0.0.1,::1'
+    );
+
+    /**
+     * Set up
+     */
+    protected function setUp()
+    {
+        $this->subject = new Logger();
+        $this->subject->setExtensionConfiguration(
+            $this->testConfiguration
+        );
+    }
+
+    /**
+     * Tear down
+     */
+    protected function tearDown()
+    {
+        unset($this->subject);
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Utility\Logger::isEntryAccepted
+     */
+    public function entryIsAccepted()
+    {
+        $this->assertTrue(
+            $this->subject->isEntryAccepted(
+                array(
+                    'severity' => 2,
+                    'extKey' => 'whatever',
+                    'ip' => '127.0.0.1'
+                )
+            )
+        );
+    }
+
+    public function validEntriesProvider()
+    {
+        return array(
+            'Severity too low' => array(
+                array(
+                    'severity' => 0,
+                    'extKey' => 'whatever',
+                    'ip' => '127.0.0.1'
+                )
+            ),
+            'Excluded extension key' => array(
+                array(
+                    'severity' => 3,
+                    'extKey' => 'foo',
+                    'ip' => '127.0.0.1'
+                )
+            ),
+            'IP does not match' => array(
+                array(
+                    'severity' => 3,
+                    'extKey' => 'whatever',
+                    'ip' => '192.168.1.1'
+                )
+            )
+        );
+    }
+
+    /**
+     * @param array $entry Log entry data
+     * @test
+     * @dataProvider validEntriesProvider
+     * @covers \Devlog\Devlog\Utility\Logger::isEntryAccepted
+     */
+    public function entryIsRefused($entry)
+    {
+        $this->assertFalse(
+            $this->subject->isEntryAccepted(
+                $entry
+            )
+        );
+    }
+
+    public function ipAddressesProvider()
+    {
+        return array(
+            'Valid IP v4' => array(
+                '127.0.0.1',
+                '',
+                '',
+                TRUE
+            ),
+            'Valid IP v6' => array(
+                '::1',
+                '',
+                '',
+                TRUE
+            ),
+            'Valid with devIPMask' => array(
+                '192.168.1.67',
+                'devIPMask',
+                '192.168.1.*',
+                TRUE
+            ),
+            'IP v4' => array(
+                '192.168.1.1',
+                '',
+                '',
+                FALSE
+            ),
+            'IP v6' => array(
+                '2001:db8::ff00:42:8329',
+                '',
+                '',
+                FALSE
+            ),
+            'devIPMask' => array(
+                '80.58.212.14',
+                'devIPMask',
+                '192.168.1.*',
+                FALSE
+            )
+        );
+    }
+
+    /**
+     * @param string $testValue IP address to test
+     * @param string $configurationOverride Override IP filter in extension configuration
+     * @param string $devIpMask Value for overriding $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
+     * @param boolean $result TRUE or FALSE, depending on IP address validity
+     * @test
+     * @dataProvider ipAddressesProvider
+     * @covers \Devlog\Devlog\Utility\Logger::isIpAddressAccepted
+     */
+    public function isIpAddressValid($testValue, $configurationOverride, $devIpMask, $result)
+    {
+        $savedIpMask = $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'];
+        // Override devIPmask
+        if (!empty($devIpMask)) {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $devIpMask;
+        }
+        // Override extension configuration
+        if (!empty($configurationOverride)) {
+            $specialConfiguration = $this->testConfiguration;
+            $specialConfiguration['ipFilter'] = $configurationOverride;
+            $this->subject->setExtensionConfiguration(
+                $specialConfiguration
+            );
+        }
+        // Perform the actual test
+        $this->assertSame(
+            $result,
+            $this->subject->isIpAddressAccepted(
+                $testValue
+            )
+        );
+        // Restore extension configuration
+        $this->subject->setExtensionConfiguration(
+            $this->testConfiguration
+        );
+        // Restore devIPmask
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $savedIpMask;
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Utility\Logger::getExtensionConfiguration
+     * @covers \Devlog\Devlog\Utility\Logger::setExtensionConfiguration
+     */
+    public function getConfigurationReturnsTestValue()
+    {
+        $this->assertSame(
+            $this->subject->getExtensionConfiguration(),
+            $this->testConfiguration
+        );
+    }
+
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Utility\Logger::isLoggingEnabled
+     */
+    public function getIsLoggingEnabledReturnsInitialValueForBoolean()
+    {
+        $this->assertTrue(
+            $this->subject->isLoggingEnabled()
+        );
+    }
+
+    /**
+     * @test
+     * @covers \Devlog\Devlog\Utility\Logger::setIsLoggingEnabled
+     */
+    public function setIsLoggingEnabledForBooleanSetsIsLoggingEnabled()
+    {
+        $this->subject->setIsLoggingEnabled(FALSE);
+
+        $this->assertAttributeEquals(
+            FALSE,
+            'isLoggingEnabled',
+            $this->subject
+        );
+    }
 }
index db8d056..52100bb 100644 (file)
 ########################################################################
 
 $EM_CONF[$_EXTKEY] = array(
-       'title' => 'Developer\'s Log',
-       'description' => 'The Developer log extension provides development logging/debugging functionality for usage of t3lib_div::devlog() and a BE module to browse the logs.',
-       'category' => 'misc',
-       'shy' => FALSE,
-       'dependencies' => '',
-       'conflicts' => '',
-       'priority' => '',
-       'loadOrder' => '',
-       'module' => 'mod1',
-       'state' => 'stable',
-       'uploadfolder' => 0,
-       'createDirs' => '',
-       'modify_tables' => '',
-       'clearCacheOnLoad' => 1,
-       'lockType' => '',
-       'author' => 'Francois Suter',
-       'author_email' => 'typo3@cobweb.ch',
-       'author_company' => '',
-       'CGLcompliance' => '',
-       'CGLcompliance_note' => '',
-       'version' => '3.0-dev',
-       'constraints' => array(
-               'depends' => array(
-                       'typo3' => '6.2.0-6.2.99',
-               ),
-               'conflicts' => array(
-               ),
-               'suggests' => array(
-               ),
-       ),
-       '_md5_values_when_last_written' => 'a:21:{s:9:"ChangeLog";s:4:"23f6";s:19:"class.tx_devlog.php";s:4:"9182";s:28:"class.tx_devlog_tceforms.php";s:4:"5e2a";s:21:"ext_conf_template.txt";s:4:"af5a";s:12:"ext_icon.gif";s:4:"cd8e";s:17:"ext_localconf.php";s:4:"a7f0";s:14:"ext_tables.php";s:4:"4845";s:14:"ext_tables.sql";s:4:"8608";s:18:"icon_tx_devlog.gif";s:4:"cd8e";s:13:"locallang.xml";s:4:"68e6";s:26:"locallang_csh_txdevlog.xml";s:4:"b9da";s:16:"locallang_db.xml";s:4:"03db";s:7:"tca.php";s:4:"162e";s:14:"doc/manual.sxw";s:4:"6ba1";s:14:"mod1/clear.gif";s:4:"cc11";s:13:"mod1/conf.php";s:4:"4129";s:14:"mod1/index.php";s:4:"2969";s:18:"mod1/locallang.xml";s:4:"68d2";s:22:"mod1/locallang_mod.xml";s:4:"5454";s:19:"mod1/moduleicon.gif";s:4:"cd8e";s:22:"res/csh_severities.png";s:4:"facf";}',
-       'suggests' => array(
-       ),
-);
-
-?>
\ No newline at end of file
+    'title' => 'Developer\'s Log',
+    'description' => 'The Developer log extension provides development logging/debugging functionality for usage of t3lib_div::devlog() and a BE module to browse the logs.',
+    'category' => 'misc',
+    'priority' => '',
+    'loadOrder' => '',
+    'module' => 'mod1',
+    'state' => 'stable',
+    'uploadfolder' => 0,
+    'createDirs' => '',
+    'modify_tables' => '',
+    'clearCacheOnLoad' => 1,
+    'lockType' => '',
+    'author' => 'Francois Suter',
+    'author_email' => 'typo3@cobweb.ch',
+    'author_company' => '',
+    'version' => '3.0-dev',
+    'constraints' => array(
+        'depends' => array(
+            'typo3' => '7.6.0-7.99.99',
+        ),
+        'conflicts' => array(
+        ),
+        'suggests' => array(
+        ),
+    ),
+);
\ No newline at end of file
index 43c8cda..1fee33d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if (!defined ('TYPO3_MODE')) {
-       die ('Access denied.');
+    die ('Access denied.');
 }
 
 // Register the logging method with the appropriate hook
index f230592..ffde468 100644 (file)
@@ -1,19 +1,19 @@
 <?php
 if (!defined ('TYPO3_MODE')) {
-       die ('Access denied.');
+    die ('Access denied.');
 }
 
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_devlog_domain_model_entry');
 
 // Add context sensitive help (csh) to the backend module and to the tx_devlog table
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
-       'tx_devlog_domain_model_entry',
-       'EXT:devlog/Resources/Private/Language/locallang_csh_txdevlog.xlf'
+    'tx_devlog_domain_model_entry',
+    'EXT:devlog/Resources/Private/Language/locallang_csh_txdevlog.xlf'
 );
 
 $pathToExtension = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('devlog');
 // Register the extension's icons
 $icons = array(
-       'entry' => $pathToExtension . 'Resources/Public/Icons/Entry.png',
+    'entry' => $pathToExtension . 'Resources/Public/Icons/Entry.png',
 );
 \TYPO3\CMS\Backend\Sprite\SpriteManager::addSingleIcons($icons, 'devlog');
index 4a01645..0f26fdc 100644 (file)
@@ -22,4 +22,4 @@ CREATE TABLE tx_devlog_domain_model_entry (
        PRIMARY KEY (uid),
        KEY parent (pid)
 
-);
+);
\ No newline at end of file