Skip to content

Commit

Permalink
Replaced reference to 'AClassContent' by 'AbstractClassContent' and u…
Browse files Browse the repository at this point in the history
…pdated some classes coding style
  • Loading branch information
eric-chau committed May 8, 2015
1 parent f8ac165 commit 2c586bb
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ This changelog references the relevant changes (bug and security fixes) done in

* __BC #295 : Coding standard class naming convention refactor in Abstract / Interface / Exception
* __BC #177 [ClassContent]__ Changed ``AContent::getParam`` and ``AContent::setParam`` API, we cannot anymore use them to set or get every parameters. To do so, use respectively ``AContent::setAllParams`` and ``AContent::getAllParams``.
* __BC #177 [ClassContent]__ Renamed method of AClassContent, from ``getDefaultParameters`` to ``getDefaultParams``.
* __BC #177 [ClassContent]__ Renamed method of AbstractClassContent, from ``getDefaultParameters`` to ``getDefaultParams``.
* __BC #188 [Bundle]__ Renamed ``AbstractBaseBundle`` to ``AbstractBundle`` and removed ABundle, every bundle must extends ``AbstractBundle`` to be compatible with BackBee REST API
* __feature #178 [Bundle] bundle's service identifier pattern and bundle's config service identifier pattern has changed__ (pattern changed from ``bundle.commentbundle`` to ``bundle.comment``, bundle's config service identifier still accessible by appending ``.config`` to bundle service identifier, which result to `bundle.comment.config``)
37 changes: 25 additions & 12 deletions ClassContent/Indexation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@
*
* @copyright Lp digital system
* @author c.rouillon <charles.rouillon@lp-digital.fr>
*
* @ORM\Entity(repositoryClass="BackBee\ClassContent\Repository\IndexationRepository")
* @ORM\Table(name="indexation",indexes={@ORM\Index(name="IDX_OWNER", columns={"owner_uid"}), @ORM\Index(name="IDX_CONTENT", columns={"content_uid"}), @ORM\Index(name="IDX_VALUE", columns={"value"}), @ORM\Index(name="IDX_SEARCH", columns={"field", "value"})})
* @ORM\Table(name="indexation",indexes={
* @ORM\Index(name="IDX_OWNER", columns={"owner_uid"}),
* @ORM\Index(name="IDX_CONTENT", columns={"content_uid"}),
* @ORM\Index(name="IDX_VALUE", columns={"value"}),
* @ORM\Index(name="IDX_SEARCH", columns={"field", "value"})
* })
*/
class Indexation
{
/**
* The indexed content.
*
* @var string
*
* @ORM\Id
* @ORM\ManyToOne(targetEntity="BackBee\ClassContent\AbstractClassContent", inversedBy="_indexation", fetch="EXTRA_LAZY")
* @ORM\JoinColumn(name="content_uid", referencedColumnName="uid")
Expand All @@ -51,6 +58,7 @@ class Indexation
* The indexed field of the content.
*
* @var string
*
* @ORM\Id
* @ORM\Column(type="string", name="field")
*/
Expand All @@ -59,7 +67,8 @@ class Indexation
/**
* The owner content of the indexed field.
*
* @var AClassContent
* @var AbstractClassContent
*
* @ORM\ManyToOne(targetEntity="BackBee\ClassContent\AbstractClassContent", fetch="EXTRA_LAZY")
* @ORM\JoinColumn(name="owner_uid", referencedColumnName="uid")
*/
Expand All @@ -69,6 +78,7 @@ class Indexation
* The value of the indexed field.
*
* @var string
*
* @ORM\Column(type="string", name="value")
*/
protected $_value;
Expand All @@ -77,6 +87,7 @@ class Indexation
* The optional callback to apply while indexing.
*
* @var string
*
* @ORM\Column(type="string", name="callback", nullable=true)
*/
protected $_callback;
Expand All @@ -92,11 +103,13 @@ class Indexation
*/
public function __construct($content = null, $field = null, $owner = null, $value = null, $callback = null)
{
$this->setContent($content)
->setField($field)
->setOwner($owner)
->setValue($value)
->setCallback($callback);
$this
->setContent($content)
->setField($field)
->setOwner($owner)
->setValue($value)
->setCallback($callback)
;
}

/**
Expand Down Expand Up @@ -144,7 +157,7 @@ public function getContent()
*
* @param string $content
*
* @return \BackBee\ClassContent\Indexation
* @return self
*/
public function setContent($content)
{
Expand All @@ -158,7 +171,7 @@ public function setContent($content)
*
* @param string $field
*
* @return \BackBee\ClassContent\Indexation
* @return self
*/
public function setField($field)
{
Expand All @@ -172,7 +185,7 @@ public function setField($field)
*
* @param \Symfony\Component\Security\Acl\Model\SecurityIdentityInterface $owner
*
* @return \BackBee\ClassContent\Indexation
* @return self
*/
public function setOwner($owner)
{
Expand All @@ -186,7 +199,7 @@ public function setOwner($owner)
*
* @param string $value
*
* @return \BackBee\ClassContent\Indexation
* @return self
*/
public function setValue($value)
{
Expand All @@ -200,7 +213,7 @@ public function setValue($value)
*
* @param function $callback
*
* @return \BackBee\ClassContent\Indexation
* @return self
*/
public function setCallback($callback)
{
Expand Down
85 changes: 60 additions & 25 deletions ClassContent/Revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@
*
* @copyright Lp digital system
* @author c.rouillon <charles.rouillon@lp-digital.fr>
*
* @ORM\Entity(repositoryClass="BackBee\ClassContent\Repository\RevisionRepository")
* @ORM\Table(name="revision", indexes={@ORM\Index(name="IDX_CONTENT", columns={"content_uid"}), @ORM\Index(name="IDX_REVISION_CLASSNAME_1", columns={"classname"}), @ORM\Index(name="IDX_DRAFT", columns={"owner", "state"})})
* @ORM\Table(name="revision", indexes={
* @ORM\Index(name="IDX_CONTENT", columns={"content_uid"}),
* @ORM\Index(name="IDX_REVISION_CLASSNAME_1", columns={"classname"}),
* @ORM\Index(name="IDX_DRAFT", columns={"owner", "state"})
* })
* @ORM\HasLifecycleCallbacks
*/
class Revision extends AbstractContent implements \Iterator, \Countable
Expand Down Expand Up @@ -103,7 +108,8 @@ class Revision extends AbstractContent implements \Iterator, \Countable
/**
* The attached revisionned content.
*
* @var \BackBee\ClassContent\AClassContent
* @var AbstractClassContent
*
* @ORM\ManyToOne(targetEntity="BackBee\ClassContent\AbstractClassContent", inversedBy="_revisions", fetch="EXTRA_LAZY")
* @ORM\JoinColumn(name="content_uid", referencedColumnName="uid")
*/
Expand All @@ -113,14 +119,16 @@ class Revision extends AbstractContent implements \Iterator, \Countable
* The entity target content classname.
*
* @var string
*
* @ORM\Column(type="string", name="classname")
*/
private $_classname;

/**
* The owner of this revision.
*
* @var \Symfony\Component\Security\Acl\Domain\UserSecurityIdentity
* @var UserSecurityIdentity
*
* @ORM\Column(type="string", name="owner")
*/
private $_owner;
Expand All @@ -146,7 +154,7 @@ class Revision extends AbstractContent implements \Iterator, \Countable
private $em;

/**
* @var \BackBee\Security\Token\BBUserToken
* @var BBUserToken
*/
private $token;

Expand Down Expand Up @@ -176,7 +184,7 @@ public function __clone()
*
* @param \Doctrine\ORM\EntityManager $em
*
* @return \BackBee\ClassContent\Revision
* @return Revision
*/
public function setEntityManager(EntityManager $em = null)
{
Expand All @@ -188,9 +196,9 @@ public function setEntityManager(EntityManager $em = null)
/**
* Sets the current BB user's token to dynamically load subrevisions.
*
* @param \BackBee\Security\Token\BBUserToken $token
* @param BBUserToken $token
*
* @return \BackBee\ClassContent\Revision
* @return Revision
*/
public function setToken(BBUserToken $token = null)
{
Expand All @@ -202,7 +210,7 @@ public function setToken(BBUserToken $token = null)
/**
* Returns the revisionned content.
*
* @return \BackBee\ClassContent\AbstractClassContent
* @return AbstractClassContent
* @codeCoverageIgnore
*/
public function getContent()
Expand All @@ -224,7 +232,7 @@ public function getClassname()
/**
* Returns the owner of the revision.
*
* @return \Symfony\Component\Security\Acl\Domain\UserSecurityIdentity
* @return UserSecurityIdentity
* @codeCoverageIgnore
*/
public function getOwner()
Expand All @@ -248,7 +256,7 @@ public function getComment()
*
* @param array $data
*
* @return \BackBee\ClassContent\AbstractClassContent the current instance content
* @return AbstractClassContent the current instance content
* @codeCoverageIgnore
*/
public function setData(array $data)
Expand All @@ -261,9 +269,9 @@ public function setData(array $data)
/**
* Sets the attached revisionned content.
*
* @param \BackBee\ClassContent\AClassContent $content
* @param AbstractClassContent $content
*
* @return \BackBee\ClassContent\AbstractClassContent the current instance content
* @return AbstractClassContent the current instance content
*/
public function setContent(AbstractClassContent $content = null)
{
Expand All @@ -281,7 +289,7 @@ public function setContent(AbstractClassContent $content = null)
*
* @param string $classname
*
* @return \BackBee\ClassContent\AbstractClassContent the current instance content
* @return AbstractClassContent the current instance content
* @codeCoverageIgnore
*/
public function setClassname($classname)
Expand All @@ -294,9 +302,9 @@ public function setClassname($classname)
/**
* Sets the owner of the revision.
*
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @param UserInterface $user
*
* @return \BackBee\ClassContent\AbstractClassContent the current instance content
* @return AbstractClassContent the current instance content
* @codeCoverageIgnore
*/
public function setOwner(UserInterface $user)
Expand All @@ -311,7 +319,7 @@ public function setOwner(UserInterface $user)
*
* @param string $comment
*
* @return \BackBee\ClassContent\AbstractClassContent the current instance content
* @return AbstractClassContent the current instance content
* @codeCoverageIgnore
*/
public function setComment($comment)
Expand All @@ -329,7 +337,10 @@ public function setComment($comment)
public function clear()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not clear an content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not clear an content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

$this->_data = array();
Expand All @@ -344,7 +355,10 @@ public function clear()
public function count()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not count an content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not count an content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

return count($this->_data);
Expand All @@ -358,7 +372,10 @@ public function count()
public function current()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not get current of a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not get current of a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

return $this->getData($this->_index);
Expand Down Expand Up @@ -386,7 +403,10 @@ public function first()
public function item($index)
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not get item of a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not get item of a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

if (0 <= $index && $index < $this->count()) {
Expand All @@ -404,7 +424,10 @@ public function item($index)
public function key()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not get key of a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not get key of a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

return $this->_index;
Expand All @@ -428,7 +451,10 @@ public function last()
public function next()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not get next of a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not get next of a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

return $this->getData($this->_index++);
Expand Down Expand Up @@ -464,7 +490,10 @@ public function pop()
public function push(AbstractClassContent $var)
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not push in a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not push in a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

if ($this->isAccepted($var)) {
Expand All @@ -482,7 +511,10 @@ public function push(AbstractClassContent $var)
public function rewind()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not rewind a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not rewind a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

$this->_index = 0;
Expand Down Expand Up @@ -532,7 +564,10 @@ public function unshift(AbstractClassContent $var)
public function valid()
{
if (!($this->_content instanceof ContentSet)) {
throw new ClassContentException(sprintf('Can not valid a content %s.', get_class($this)), ClassContentException::UNKNOWN_ERROR);
throw new ClassContentException(
sprintf('Can not valid a content %s.', get_class($this)),
ClassContentException::UNKNOWN_ERROR
);
}

return isset($this->_data[$this->_index]);
Expand Down
Loading

0 comments on commit 2c586bb

Please sign in to comment.