Model/Document.php
author ymh <ymh.work@gmail.com>
Fri, 26 Sep 2014 10:04:40 +0200
changeset 136 f209fcb0df6c
parent 65 ba6b8e38d90e
permissions -rwxr-xr-x
Added tag V00.18 for changeset ab728cb3632c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/*
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * This file is part of the WikiTagBundle package.
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * (c) IRI <http://www.iri.centrepompidou.fr/>
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * For the full copyright and license information, please view the LICENSE
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * file that was distributed with this source code.
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
namespace IRI\Bundle\WikiTagBundle\Model;
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
14
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    13
use Doctrine\Common\Collections\ArrayCollection;
27
8551d844b4f3 Correct memory problem
ymh <ymh.work@gmail.com>
parents: 23
diff changeset
    14
use Doctrine\Common\Util\Debug;
14
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    15
17
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 3
diff changeset
    16
abstract class Document implements DocumentInterface {
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    /**
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    * @var integer $id
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    */
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    protected $id;
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    /**
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
     * @var boolean $manualOrder
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
     */
3
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    26
    protected $manualOrder = false;
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    27
    
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    28
    /**
63
774ba82dca59 add tests and fixtures
ymh <ymh.work@gmail.com>
parents: 62
diff changeset
    29
     * @var mixed $externalId
3
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    30
     */
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    31
    protected $externalId;
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    
14
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    33
    /**
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    34
     * @var ArrayCollection $tags
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    35
     */
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    36
    protected $tags;
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    37
    
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    38
    /**
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    39
     * @var string tagsStr
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    40
     */
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    41
    protected $tagsStr;
62
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
    42
        
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
    43
   /**
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
    44
    * @var DateTime
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
    45
    */
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
    46
    protected $createdAt;
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    47
    
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    /**
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
     * Get id
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
     *
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
     * @return integer
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
     */
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
    public function getId()
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
    {
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
        return $this->id;
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
    }
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
    /**
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
    * Set manualOrder
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
    *
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
    * @param boolean $manualOrder
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
    */
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
    function setManualOrder($manualOrder)
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
    {
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
        $this->manualOrder = $manualOrder;
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
    }
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
    
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
    /**
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
     * Get manualOrder
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
     *
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
     * @return boolean
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
     */
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
    function getManualOrder()
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
    {
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
        return $this->manualOrder;
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
    }
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
    
3
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    80
    /**
58
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
    81
     * (non-PHPdoc)
3
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    82
     * @see IRI\Bundle\WikiTagBundle\Model.BaseDocumentInterface::setExternalId()
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    83
     */
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    84
    function setExternalId($externalId)
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    85
    {
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    86
        $this->externalId = $externalId;
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    87
    }
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    88
    
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    89
    /**
58
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
    90
     * (non-PHPdoc)
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
    91
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::getExternalId()
3
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    92
     */
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    93
    function getExternalId()
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    94
    {
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    95
        return $this->externalId;
976d922e52f0 link document lifecycle
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    96
    }
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
    
14
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
    98
    /**
58
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
    99
     * (non-PHPdoc)
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   100
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::getTags()
14
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   101
     */
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   102
    function getTags()
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   103
    {
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   104
        return $this->tags;
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   105
    }
673b2766024e Update ORM configuration to allow JOIN between Tag and DocumentTag. TagList template has now the number of documents by tag.
cavaliet
parents: 3
diff changeset
   106
    
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   107
    /**
58
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   108
     * (non-PHPdoc)
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   109
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::setTagsStr()
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   110
     */
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   111
    function setTagsStr($tagsStr)
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   112
    {
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   113
        $this->tagsStr = $tagsStr;
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   114
    }
58
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   115
    
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   116
   	/**
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   117
     * (non-PHPdoc)
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   118
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::getTagsStr()
87bf6ec8af90 add unsemantized status
ymh <ymh.work@gmail.com>
parents: 27
diff changeset
   119
     */
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   120
    function getTagsStr()
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   121
    {
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   122
        return $this->tagsStr;
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   123
    }
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   124
    
62
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   125
    /**
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   126
     * (non-PHPdoc)
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   127
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::getCreatedAt()
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   128
     */
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   129
    function getCreatedAt()
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   130
    {
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   131
        return $this->createdAt;
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   132
    }
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   133
    
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   134
    /**
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   135
    *
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   136
    * construct the class
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   137
    */
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   138
    function __construct()
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   139
    {
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   140
        $this->createdAt = new \DateTime("now", new \DateTimeZone('UTC'));
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   141
    }
10be6b9e55e7 add creation timestamp on document tag and document tag
ymh <ymh.work@gmail.com>
parents: 58
diff changeset
   142
    
65
ba6b8e38d90e Correct event mamangement in hdabo_sf
ymh <ymh.work@gmail.com>
parents: 63
diff changeset
   143
    /**
ba6b8e38d90e Correct event mamangement in hdabo_sf
ymh <ymh.work@gmail.com>
parents: 63
diff changeset
   144
     * (non-PHPdoc)
ba6b8e38d90e Correct event mamangement in hdabo_sf
ymh <ymh.work@gmail.com>
parents: 63
diff changeset
   145
     * @see IRI\Bundle\WikiTagBundle\Model.DocumentInterface::__toString()
ba6b8e38d90e Correct event mamangement in hdabo_sf
ymh <ymh.work@gmail.com>
parents: 63
diff changeset
   146
     */
27
8551d844b4f3 Correct memory problem
ymh <ymh.work@gmail.com>
parents: 23
diff changeset
   147
    public function __toString()
8551d844b4f3 Correct memory problem
ymh <ymh.work@gmail.com>
parents: 23
diff changeset
   148
    {
8551d844b4f3 Correct memory problem
ymh <ymh.work@gmail.com>
parents: 23
diff changeset
   149
        return print_r(Debug::export($this, 3),true);
8551d844b4f3 Correct memory problem
ymh <ymh.work@gmail.com>
parents: 23
diff changeset
   150
    }
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 20
diff changeset
   151
2
13f43f53d0ba first implementation
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
}