epub: true
mobi: true
templating_formats:
- html: true
+ html: false
force_redirects:
html: true
failed_validation: HTTP_BAD_REQUEST
use JMS\Serializer\Annotation\VirtualProperty;
use Symfony\Component\Validator\Constraints as Assert;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
use Wallabag\UserBundle\Entity\User;
/**
*/
class Annotation
{
+ use EntityTimestampsTrait;
+
/**
* @var int
*
return $this->text;
}
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function timestamps()
- {
- if (null === $this->createdAt) {
- $this->createdAt = new \DateTime();
- }
- $this->updatedAt = new \DateTime();
- }
-
/**
* Get created.
*
$clientForm->handleRequest($request);
if ($clientForm->isSubmitted() && $clientForm->isValid()) {
- $client->setAllowedGrantTypes(['client_credentials', 'token', 'authorization_code', 'password', 'refresh_token']);
+ $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
$em->persist($client);
$em->flush();
use JMS\Serializer\Annotation\XmlRoot;
use Symfony\Component\Validator\Constraints as Assert;
use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
use Wallabag\UserBundle\Entity\User;
/**
*/
class Entry
{
+ use EntityTimestampsTrait;
+
/** @Serializer\XmlAttribute */
/**
* @var int
return $this->updatedAt;
}
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function timestamps()
- {
- if (null === $this->createdAt) {
- $this->createdAt = new \DateTime();
- }
-
- $this->updatedAt = new \DateTime();
- }
-
/**
* @return ArrayCollection<Annotation>
*/
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
use Wallabag\UserBundle\Entity\User;
/**
*/
class SiteCredential
{
+ use EntityTimestampsTrait;
+
/**
* @var int
*
{
return $this->user;
}
-
- /**
- * @ORM\PrePersist
- */
- public function timestamps()
- {
- if (null === $this->createdAt) {
- $this->createdAt = new \DateTime();
- }
- }
}
--- /dev/null
+<?php
+
+namespace Wallabag\CoreBundle\Helper;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Trait to handle created & updated date of an Entity.
+ */
+trait EntityTimestampsTrait
+{
+ /**
+ * @ORM\PrePersist
+ * @ORM\PreUpdate
+ */
+ public function timestamps()
+ {
+ if (null === $this->createdAt) {
+ $this->createdAt = new \DateTime();
+ }
+
+ $this->updatedAt = new \DateTime();
+ }
+}
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
/**
* User.
*/
class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface
{
+ use EntityTimestampsTrait;
+
/** @Serializer\XmlAttribute */
/**
* @var int
$this->roles = ['ROLE_USER'];
}
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function timestamps()
- {
- if (null === $this->createdAt) {
- $this->createdAt = new \DateTime();
- }
-
- $this->updatedAt = new \DateTime();
- }
-
/**
* Set name.
*
$this->assertContains('My app', $alert[0]);
}
- public function testCreateTokenFromPasswords()
+ public function testCreateToken()
{
$client = $this->getClient();
$apiClient = $this->createApiClientForUser('admin');
$this->assertArrayHasKey('refresh_token', $data);
}
- public function testCreateTokenFromClientCredentialsOnly()
- {
- $client = $this->getClient();
- $apiClient = $this->createApiClientForUser('admin', ['client_credentials']);
-
- $client->request('POST', '/oauth/v2/token', [
- 'grant_type' => 'client_credentials',
- 'client_id' => $apiClient->getPublicId(),
- 'client_secret' => $apiClient->getSecret(),
- ]);
-
- $this->assertSame(200, $client->getResponse()->getStatusCode());
-
- $data = json_decode($client->getResponse()->getContent(), true);
- $this->assertArrayHasKey('access_token', $data);
- $this->assertArrayHasKey('expires_in', $data);
- $this->assertArrayHasKey('token_type', $data);
- // Client Credentials created-clients have no refresh tokens
- }
-
public function testListingClient()
{
$this->logInAs('admin');