diff --git a/composer.json b/composer.json index da99fc5..13d9df0 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "clear-config-cache": "php bin/clear-config-cache.php", "cs-check": "phpcs", "cs-fix": "phpcbf", - "serve": "php -S 0.0.0.0:8080 -t public public/index.php", + "serve": "php -S 0.0.0.0:8888 -t public public/index.php", "test": "phpunit --colors=always", "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", "upload-coverage": "coveralls -v" diff --git a/config/autoload/doctrine.global.php b/config/autoload/doctrine.global.php index 75f17d0..83e0fb7 100644 --- a/config/autoload/doctrine.global.php +++ b/config/autoload/doctrine.global.php @@ -32,10 +32,10 @@ return [ // 'day' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, // 'hour' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, // 'minute' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, - 'month' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'month' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, // 'quarter' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, // 'second' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, - 'year' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, +// 'year' => Oro\ORM\Query\AST\Functions\SimpleFunction::class, // 'sign' => Oro\ORM\Query\AST\Functions\Numeric\Sign::class, // 'pow' => Oro\ORM\Query\AST\Functions\Numeric\Pow::class, ], @@ -53,7 +53,7 @@ return [ 'event_manager' => [ 'orm_default' => [ 'subscribers' => [ - Gedmo\Timestampable\TimestampableListener::class, +// Gedmo\Timestampable\TimestampableListener::class, // 'Gedmo\Tree\TreeListener', // 'Gedmo\SoftDeleteable\SoftDeleteableListener', // 'Gedmo\Translatable\TranslatableListener', diff --git a/src/App/Action/StoreAction.php b/src/App/Action/StoreAction.php index c872b61..5ac93b0 100644 --- a/src/App/Action/StoreAction.php +++ b/src/App/Action/StoreAction.php @@ -20,7 +20,7 @@ class StoreAction extends AbstractAction public function create(ServerRequestInterface $request, DelegateInterface $delegate) { $hashKey = $request->getAttribute('hashKey'); - $direction = $request->getAttribute('direction','received'); + $direction = $request->getAttribute('direction'); $mappedDirection = Sms::MAP_DIRECTIONS[$direction]; $requestData = $this->getRequestData($request); $isStored = $this->smsStore->storeSms($hashKey, $mappedDirection, $requestData); diff --git a/src/App/ConfigProvider.php b/src/App/ConfigProvider.php index 7fd8b41..e1c87fd 100644 --- a/src/App/ConfigProvider.php +++ b/src/App/ConfigProvider.php @@ -38,6 +38,7 @@ class ConfigProvider ], 'factories' => [ Action\HomePageAction::class => Action\HomePageFactory::class, + Action\StoreAction::class => Action\StoreFactory::class, Service\SmsStoreService::class => Service\SmsStoreServiceFactory::class, ], diff --git a/src/App/Entity/Sms.php b/src/App/Entity/Sms.php index b9c9e5e..a75c5a7 100644 --- a/src/App/Entity/Sms.php +++ b/src/App/Entity/Sms.php @@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM; * indexes={ * @ORM\Index(name="contact_name", columns={"contact_name"}), * @ORM\Index(name="contact_number", columns={"contact_number"}), - * @ORM\Index(name="when", columns={"when"}), + * @ORM\Index(name="occured_at", columns={"occured_at"}), * @ORM\Index(name="direction", columns={"direction"}) * } * ) @@ -56,10 +56,10 @@ class Sms implements \JsonSerializable private $text; /** - * @ORM\Column(name="when", type="datetime", nullable=false) + * @ORM\Column(name="occured_at", type="datetime", nullable=false) * @var \DateTime */ - private $when; + private $occuredAt; /** * @ORM\Column(name="direction", type="integer", length=255, nullable=false) @@ -149,18 +149,18 @@ class Sms implements \JsonSerializable /** * @return \DateTime */ - public function getWhen(): \DateTime + public function getOccuredAt(): \DateTime { - return $this->when; + return $this->occuredAt; } /** - * @param \DateTime $when + * @param \DateTime $occuredAt * @return Sms */ - public function setWhen(\DateTime $when): Sms + public function setOccuredAt(\DateTime $occuredAt): Sms { - $this->when = $when; + $this->occuredAt = $occuredAt; return $this; } @@ -214,7 +214,7 @@ class Sms implements \JsonSerializable 'contactName' => $this->getContactName(), 'contactNumber' => $this->getContactNumber(), 'text' => $this->getText(), - 'when' => $this->getWhen(), + 'when' => $this->getOccuredAt(), 'direction' => $this->getDirection(), 'owner' => $this->getOwner(), ]; diff --git a/src/App/Entity/User.php b/src/App/Entity/User.php index c6db21a..fcb8149 100644 --- a/src/App/Entity/User.php +++ b/src/App/Entity/User.php @@ -10,10 +10,8 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table( * name="user", * indexes={ - * @ORM\Index(name="contact_name", columns={"contact_name"}), - * @ORM\Index(name="contact_number", columns={"contact_number"}), - * @ORM\Index(name="when", columns={"when"}), - * @ORM\Index(name="direction", columns={"direction"}) + * @ORM\Index(name="name", columns={"name"}), + * @ORM\Index(name="hash_key", columns={"hash_key"}), * } * ) */ @@ -40,7 +38,7 @@ class User implements \JsonSerializable private $hashKey; /** - * @ORM\OneToMany(targetEntity="Fault", mappedBy="institute") + * @ORM\OneToMany(targetEntity="Sms", mappedBy="owner") * @var Sms[]|ArrayCollection */ private $smsMessages; diff --git a/src/App/Service/SmsStoreService.php b/src/App/Service/SmsStoreService.php index 48124c5..f0f5e24 100644 --- a/src/App/Service/SmsStoreService.php +++ b/src/App/Service/SmsStoreService.php @@ -27,7 +27,7 @@ class SmsStoreService $sms->setDirection($direction) ->setContactName($requestData['contactName']) ->setContactNumber($requestData['contactNumber']) - ->setWhen($requestData['when']) + ->setOccuredAt(new \DateTime($requestData['when'])) ->setOwner($user) ->setText($requestData['text']); $this->em->persist($sms); @@ -49,7 +49,7 @@ class SmsStoreService if($user === null) { $user = new User(); - $user->setHashKey($hashKey); + $user->setHashKey($hashKey)->setName("Unknown"); $this->em->persist($user); $this->em->flush(); }