* some minor fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
],
|
||||
|
||||
@@ -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(),
|
||||
];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user