Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Session often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Session, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
51 | class Session implements SessionInterface |
||
52 | { |
||
53 | /** |
||
54 | * @var CmisBindingInterface |
||
55 | */ |
||
56 | protected $binding; |
||
57 | |||
58 | /** |
||
59 | * @var Cache |
||
60 | */ |
||
61 | protected $cache; |
||
62 | |||
63 | /** |
||
64 | * @var OperationContextInterface |
||
65 | */ |
||
66 | private $defaultContext; |
||
67 | |||
68 | /** |
||
69 | * @var CmisBindingsHelper |
||
70 | */ |
||
71 | protected $cmisBindingHelper; |
||
72 | |||
73 | /** |
||
74 | * @var ObjectFactoryInterface |
||
75 | */ |
||
76 | private $objectFactory; |
||
77 | |||
78 | /** |
||
79 | * @var RepositoryInfoInterface |
||
80 | */ |
||
81 | protected $repositoryInfo; |
||
82 | |||
83 | /** |
||
84 | * @var array |
||
85 | */ |
||
86 | protected $parameters = []; |
||
87 | |||
88 | /** |
||
89 | * @var Cache |
||
90 | */ |
||
91 | protected $typeDefinitionCache; |
||
92 | |||
93 | /** |
||
94 | * @var Cache |
||
95 | */ |
||
96 | protected $objectTypeCache; |
||
97 | |||
98 | /** |
||
99 | * @var Updatability[] |
||
100 | */ |
||
101 | protected static $createUpdatability = []; |
||
102 | |||
103 | /** |
||
104 | * @var Updatability[] |
||
105 | */ |
||
106 | protected static $createAndCheckoutUpdatability = []; |
||
107 | |||
108 | /** |
||
109 | * @param array $parameters |
||
110 | * @param ObjectFactoryInterface|null $objectFactory |
||
111 | * @param Cache|null $cache |
||
112 | * @param Cache|null $typeDefinitionCache |
||
113 | * @param Cache|null $objectTypeCache |
||
114 | * @param CmisBindingsHelper|null $cmisBindingHelper |
||
115 | * @throws CmisInvalidArgumentException |
||
116 | * @throws IllegalStateException |
||
117 | */ |
||
118 | public function __construct( |
||
164 | 8 | ||
165 | 8 | /** |
|
166 | * Create an object factory based on the SessionParameter::OBJECT_FACTORY_CLASS. If not set it returns an instance |
||
167 | * of ObjectFactory. |
||
168 | * |
||
169 | * @return ObjectFactoryInterface |
||
170 | * @throws \RuntimeException |
||
171 | */ |
||
172 | protected function createObjectFactory() |
||
195 | |||
196 | /** |
||
197 | * Returns an instance of the ObjectFactory. |
||
198 | * This methods is primarily required for unit testing. |
||
199 | * |
||
200 | * @return ObjectFactory |
||
201 | */ |
||
202 | protected function createDefaultObjectFactoryInstance() |
||
206 | 6 | ||
207 | /** |
||
208 | * Create a cache instance based on the given session parameter SessionParameter::CACHE_CLASS. |
||
209 | * If no session parameter SessionParameter::CACHE_CLASS is defined, the default Cache implementation will be used. |
||
210 | * |
||
211 | * @return Cache |
||
212 | * @throws \InvalidArgumentException |
||
213 | */ |
||
214 | protected function createCache() |
||
242 | |||
243 | /** |
||
244 | * Returns an instance of the Doctrine ArrayCache. |
||
245 | * This methods is primarily required for unit testing. |
||
246 | * |
||
247 | * @return CacheProvider |
||
248 | */ |
||
249 | protected function createDefaultCacheInstance() |
||
253 | 7 | ||
254 | /** |
||
255 | * Get the cache instance |
||
256 | * |
||
257 | * @return CacheProvider |
||
258 | */ |
||
259 | public function getCache() |
||
263 | 3 | ||
264 | /** |
||
265 | * Applies ACL changes to an object and dependent objects. Only direct ACEs can be added and removed. |
||
266 | * |
||
267 | * @param ObjectIdInterface $objectId the ID the object |
||
268 | * @param AceInterface[] $addAces of ACEs to be added or <code>null</code> if no ACEs should be added |
||
269 | * @param AceInterface[] $removeAces list of ACEs to be removed or <code>null</code> if no ACEs should be removed |
||
270 | * @param AclPropagation|null $aclPropagation value that defines the propagation of the ACE changes; |
||
271 | * <code>null</code> is equal to AclPropagation.REPOSITORYDETERMINED |
||
272 | * @return AclInterface the new ACL of the object |
||
273 | */ |
||
274 | public function applyAcl( |
||
282 | |||
283 | /** |
||
284 | * Applies a set of policies to an object. |
||
285 | * |
||
286 | * @param ObjectIdInterface $objectId the ID the object |
||
287 | * @param ObjectIdInterface[] $policyIds the IDs of the policies to be applied |
||
288 | * @return mixed |
||
289 | */ |
||
290 | public function applyPolicies(ObjectIdInterface $objectId, array $policyIds) |
||
294 | |||
295 | /** |
||
296 | * Updates multiple objects in one request. |
||
297 | * |
||
298 | * @param CmisObjectInterface[] $objects |
||
299 | * @param mixed[] $properties |
||
300 | * @param string[] $addSecondaryTypeIds |
||
301 | * @param string[] $removeSecondaryTypeIds |
||
302 | * @return BulkUpdateObjectIdAndChangeTokenInterface[] |
||
303 | */ |
||
304 | public function bulkUpdateProperties( |
||
312 | |||
313 | /** |
||
314 | * Clears all cached data. |
||
315 | */ |
||
316 | public function clear() |
||
320 | |||
321 | /** |
||
322 | * Creates a new document. The stream in contentStream is consumed but not closed by this method. |
||
323 | * |
||
324 | * @param string[] $properties The property values that MUST be applied to the newly-created document object. |
||
325 | * @param ObjectIdInterface|null $folderId If specified, the identifier for the folder that MUST be the parent |
||
326 | * folder for the newly-created document object. This parameter MUST be specified if the repository does NOT |
||
327 | * support the optional "unfiling" capability. |
||
328 | * @param StreamInterface|null $contentStream The content stream that MUST be stored for the newly-created document |
||
329 | * object. The method of passing the contentStream to the server and the encoding mechanism will be specified |
||
330 | * by each specific binding. MUST be required if the type requires it. |
||
331 | * @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the |
||
332 | * newly-created object MUST be. Valid values are: |
||
333 | * <code>none</code> |
||
334 | * (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
||
335 | * document. |
||
336 | * <code>checkedout</code> |
||
337 | * The document MUST be created in the checked-out state. The checked-out document MAY be |
||
338 | * visible to other users. |
||
339 | * <code>major</code> |
||
340 | * (default, if the object-type is versionable) The document MUST be created as a major version. |
||
341 | * <code>minor</code> |
||
342 | * The document MUST be created as a minor version. |
||
343 | * @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created |
||
344 | * document object. |
||
345 | * @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, |
||
346 | * either using the ACL from folderId if specified, or being applied if no folderId is specified. |
||
347 | * @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document |
||
348 | * object, either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
||
349 | * @return ObjectIdInterface|null the object ID of the new document or <code>null</code> if the document could not |
||
350 | * be created. |
||
351 | * @throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty |
||
352 | * property list is given |
||
353 | */ |
||
354 | public function createDocument( |
||
390 | |||
391 | /** |
||
392 | * Creates a new document from a source document. |
||
393 | * |
||
394 | * @param ObjectIdInterface $source The identifier for the source document. |
||
395 | * @param string[] $properties The property values that MUST be applied to the object. This list of properties |
||
396 | * SHOULD only contain properties whose values differ from the source document. |
||
397 | * @param ObjectIdInterface|null $folderId If specified, the identifier for the folder that MUST be the parent |
||
398 | * folder for the newly-created document object. This parameter MUST be specified if the repository does NOT |
||
399 | * support the optional "unfiling" capability. |
||
400 | * @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the |
||
401 | * newly-created object MUST be. Valid values are: |
||
402 | * <code>none</code> |
||
403 | * (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
||
404 | * document. |
||
405 | * <code>checkedout</code> |
||
406 | * The document MUST be created in the checked-out state. The checked-out document MAY be |
||
407 | * visible to other users. |
||
408 | * <code>major</code> |
||
409 | * (default, if the object-type is versionable) The document MUST be created as a major version. |
||
410 | * <code>minor</code> |
||
411 | * The document MUST be created as a minor version. |
||
412 | * @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created |
||
413 | * document object. |
||
414 | * @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, |
||
415 | * either using the ACL from folderId if specified, or being applied if no folderId is specified. |
||
416 | * @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document |
||
417 | * object, either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
||
418 | * @return ObjectIdInterface|null the object ID of the new document or <code>null</code> if the document could not |
||
419 | * be created. |
||
420 | * @throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty |
||
421 | * property list is given |
||
422 | */ |
||
423 | public function createDocumentFromSource( |
||
472 | |||
473 | /** |
||
474 | * Creates a new folder. |
||
475 | * |
||
476 | * @param string[] $properties |
||
477 | * @param ObjectIdInterface $folderId |
||
478 | * @param PolicyInterface[] $policies |
||
479 | * @param AceInterface[] $addAces |
||
480 | * @param AceInterface[] $removeAces |
||
481 | * @return ObjectIdInterface the object ID of the new folder |
||
482 | * @throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty |
||
483 | * property list is given |
||
484 | */ |
||
485 | View Code Duplication | public function createFolder( |
|
508 | |||
509 | /** |
||
510 | * Creates a new item. |
||
511 | * |
||
512 | * @param string[] $properties |
||
513 | * @param ObjectIdInterface $folderId |
||
514 | * @param PolicyInterface[] $policies |
||
515 | * @param AceInterface[] $addAces |
||
516 | * @param AceInterface[] $removeAces |
||
517 | * @return ObjectIdInterface the object ID of the new item |
||
518 | * @throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty |
||
519 | * property list is given |
||
520 | */ |
||
521 | View Code Duplication | public function createItem( |
|
544 | |||
545 | /** |
||
546 | * Creates an object ID from a String. |
||
547 | * |
||
548 | * @param string $id |
||
549 | * @return ObjectIdInterface the object ID object |
||
550 | */ |
||
551 | public function createObjectId($id) |
||
555 | |||
556 | /** |
||
557 | * Creates a new operation context object with the given properties. |
||
558 | * |
||
559 | * @param string[] $filter the property filter, a comma separated string of query names or "*" for all |
||
560 | * properties or <code>null</code> to let the repository determine a set of properties |
||
561 | * @param boolean $includeAcls indicates whether ACLs should be included or not |
||
562 | * @param boolean $includeAllowableActions indicates whether Allowable Actions should be included or not |
||
563 | * @param boolean $includePolicies indicates whether policies should be included or not |
||
564 | * @param IncludeRelationships|null $includeRelationships enum that indicates if and which |
||
565 | * relationships should be includes |
||
566 | * @param string[] $renditionFilter the rendition filter or <code>null</code> for no renditions |
||
567 | * @param boolean $includePathSegments indicates whether path segment or the relative path segment should |
||
568 | * be included or not |
||
569 | * @param string|null $orderBy the object order, a comma-separated list of query names and the ascending |
||
570 | * modifier "ASC" or the descending modifier "DESC" for each query name |
||
571 | * @param boolean $cacheEnabled flag that indicates if the object cache should be used |
||
572 | * @param integer $maxItemsPerPage the max items per page/batch |
||
573 | * @return OperationContextInterface the newly created operation context object |
||
574 | */ |
||
575 | public function createOperationContext( |
||
605 | |||
606 | /** |
||
607 | * Creates a new policy. |
||
608 | * |
||
609 | * @param string[] $properties |
||
610 | * @param ObjectIdInterface $folderId |
||
611 | * @param PolicyInterface[] $policies |
||
612 | * @param AceInterface[] $addAces |
||
613 | * @param AceInterface[] $removeAces |
||
614 | * @return ObjectIdInterface the object ID of the new policy |
||
615 | */ |
||
616 | public function createPolicy( |
||
625 | |||
626 | /** |
||
627 | * Creates a query statement for a query of one primary type joined by zero or more secondary types. |
||
628 | * |
||
629 | * Generates something like this: |
||
630 | * `SELECT d.cmis:name,s.SecondaryStringProp FROM cmis:document AS d JOIN MySecondaryType AS s ON |
||
631 | * d.cmis:objectId=s.cmis:objectId WHERE d.cmis:name LIKE ? ORDER BY d.cmis:name,s.SecondaryIntegerProp` |
||
632 | * |
||
633 | * @param string[] $selectPropertyIds the property IDs in the SELECT statement, |
||
634 | * if <code>null</code> all properties are selected |
||
635 | * @param string[] $fromTypes a Map of type aliases (keys) and type IDs (values), the Map must contain |
||
636 | * exactly one primary type and zero or more secondary types |
||
637 | * @param string|null $whereClause an optional WHERE clause with placeholders ('?'), see QueryStatement for details |
||
638 | * @param string[] $orderByPropertyIds an optional list of properties IDs for the ORDER BY clause |
||
639 | * @return QueryStatementInterface a new query statement object |
||
640 | * @throws CmisInvalidArgumentException |
||
641 | */ |
||
642 | public function createQueryStatement( |
||
657 | |||
658 | /** |
||
659 | * Creates a new relationship between 2 objects. |
||
660 | * |
||
661 | * @param string[] $properties |
||
662 | * @param PolicyInterface[] $policies |
||
663 | * @param AceInterface[] $addAces |
||
664 | * @param AceInterface[] $removeAces |
||
665 | * @return ObjectIdInterface|null the object ID of the new relationship or <code>null</code> if the relationship |
||
666 | * could not be created |
||
667 | */ |
||
668 | public function createRelationship( |
||
692 | |||
693 | /** |
||
694 | * Creates a new type. |
||
695 | * |
||
696 | * @param TypeDefinitionInterface $type |
||
697 | * @return ObjectTypeInterface the new type definition |
||
698 | * @throws CmisNotSupportedException If repository version 1.0 |
||
699 | */ |
||
700 | View Code Duplication | public function createType(TypeDefinitionInterface $type) |
|
710 | |||
711 | /** |
||
712 | * Deletes an object and, if it is a document, all versions in the version series. |
||
713 | * |
||
714 | * @param ObjectIdInterface $objectId the ID of the object |
||
715 | * @param boolean $allVersions if this object is a document this parameter defines |
||
716 | * if only this version or all versions should be deleted |
||
717 | */ |
||
718 | public function delete(ObjectIdInterface $objectId, $allVersions = true) |
||
727 | |||
728 | /** |
||
729 | * Deletes a type. |
||
730 | * |
||
731 | * @param string $typeId the ID of the type to delete |
||
732 | * @throws CmisNotSupportedException If repository version 1.0 |
||
733 | */ |
||
734 | View Code Duplication | public function deleteType($typeId) |
|
743 | |||
744 | /** |
||
745 | * Fetches the ACL of an object from the repository. |
||
746 | * |
||
747 | * @param ObjectIdInterface $objectId the ID the object |
||
748 | * @param boolean $onlyBasicPermissions if <code>true</code> the repository should express the ACL only with the |
||
749 | * basic permissions defined in the CMIS specification; if <code>false</code> the repository can express the |
||
750 | * ACL with basic and repository specific permissions |
||
751 | * @return AclInterface the ACL of the object |
||
752 | */ |
||
753 | public function getAcl(ObjectIdInterface $objectId, $onlyBasicPermissions) |
||
757 | |||
758 | /** |
||
759 | * Returns the underlying binding object. |
||
760 | * |
||
761 | * @return CmisBindingInterface the binding object |
||
762 | */ |
||
763 | public function getBinding() |
||
767 | 8 | ||
768 | /** |
||
769 | * Returns all checked out documents with the given OperationContext. |
||
770 | * |
||
771 | * @param OperationContextInterface|null $context |
||
772 | * @return DocumentInterface[] |
||
773 | */ |
||
774 | public function getCheckedOutDocs(OperationContextInterface $context = null) |
||
778 | |||
779 | /** |
||
780 | * @return CmisBindingsHelper |
||
781 | */ |
||
782 | protected function getCmisBindingHelper() |
||
786 | 8 | ||
787 | /** |
||
788 | * Returns the content changes. |
||
789 | * |
||
790 | * @param string $changeLogToken the change log token to start from or <code>null</code> to start from |
||
791 | * the first available event in the repository |
||
792 | * @param boolean $includeProperties indicates whether changed properties should be included in the result or not |
||
793 | * @param integer|null $maxNumItems maximum numbers of events |
||
794 | * @param OperationContextInterface|null $context the OperationContext |
||
795 | * @return ChangeEventsInterface the change events |
||
796 | */ |
||
797 | public function getContentChanges( |
||
818 | |||
819 | /** |
||
820 | * Retrieves the main content stream of a document. |
||
821 | * |
||
822 | * @param ObjectIdInterface $docId the ID of the document |
||
823 | * @param string|null $streamId the stream ID |
||
824 | * @param integer|null $offset the offset of the stream or <code>null</code> to read the stream from the beginning |
||
825 | * @param integer|null $length the maximum length of the stream or <code>null</code> to read to the end of the |
||
826 | * stream |
||
827 | * @return StreamInterface|null the content stream or <code>null</code> if the |
||
828 | * document has no content stream |
||
829 | */ |
||
830 | public function getContentStream(ObjectIdInterface $docId, $streamId = null, $offset = null, $length = null) |
||
840 | |||
841 | /** |
||
842 | * Returns the current default operation parameters for filtering, paging and caching. |
||
843 | * |
||
844 | * @return OperationContextInterface the default operation context |
||
845 | */ |
||
846 | public function getDefaultContext() |
||
850 | 1 | ||
851 | /** |
||
852 | 1 | * Returns the latest change log token. |
|
853 | * |
||
854 | * In contrast to the repository info, this change log token is *not cached*. |
||
855 | * This method requests the token from the repository every single time it is called. |
||
856 | * |
||
857 | * @return string|null the latest change log token or <code>null</code> if the repository doesn't provide one |
||
858 | */ |
||
859 | public function getLatestChangeLogToken() |
||
863 | |||
864 | /** |
||
865 | * Returns the latest version in a version series. |
||
866 | * |
||
867 | * @param ObjectIdInterface $objectId the document ID of an arbitrary version in the version series |
||
868 | * @param boolean $major if <code>true</code> the latest major version will be returned, |
||
869 | * otherwise the very last version will be returned |
||
870 | * @param OperationContextInterface|null $context the OperationContext to use |
||
871 | * @return DocumentInterface the latest document version |
||
872 | */ |
||
873 | public function getLatestDocumentVersion( |
||
880 | |||
881 | /** |
||
882 | * Get the current locale to be used for this session. |
||
883 | * |
||
884 | * @return \Locale the current locale, may be <code>null</code> |
||
885 | */ |
||
886 | public function getLocale() |
||
890 | |||
891 | /** |
||
892 | * @param ObjectIdInterface $objectId the object ID |
||
893 | * @param OperationContextInterface|null $context the OperationContext to use |
||
894 | * @return CmisObjectInterface the requested object |
||
895 | * @throws CmisObjectNotFoundException - if an object with the given ID doesn't exist |
||
896 | */ |
||
897 | public function getObject(ObjectIdInterface $objectId, OperationContextInterface $context = null) |
||
930 | |||
931 | /** |
||
932 | * Returns a CMIS object from the session cache. If the object is not in the cache or the given OperationContext |
||
933 | * has caching turned off, it will load the object from the repository and puts it into the cache. |
||
934 | * This method might return a stale object if the object has been found in the cache and has been changed in or |
||
935 | * removed from the repository. Use CmisObject::refresh() and CmisObject::refreshIfOld() to update the object |
||
936 | * if necessary. |
||
937 | * |
||
938 | * @param string $path the object path |
||
939 | * @param OperationContextInterface|null $context the OperationContext to use |
||
940 | * @return CmisObjectInterface Returns a CMIS object from the session cache. |
||
941 | * @throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> |
||
942 | * if path is empty. |
||
943 | * @throws CmisObjectNotFoundException - if an object with the given path doesn't exist |
||
944 | */ |
||
945 | public function getObjectByPath($path, OperationContextInterface $context = null) |
||
974 | |||
975 | /** |
||
976 | * Gets a factory object that provides methods to create the objects used by this API. |
||
977 | * |
||
978 | * @return ObjectFactoryInterface the repository info |
||
979 | */ |
||
980 | public function getObjectFactory() |
||
984 | 3 | ||
985 | /** |
||
986 | 3 | * Fetches the relationships from or to an object from the repository. |
|
987 | * |
||
988 | * @param ObjectIdInterface $objectId |
||
989 | * @param boolean $includeSubRelationshipTypes |
||
990 | * @param RelationshipDirection $relationshipDirection |
||
991 | * @param ObjectTypeInterface $type |
||
992 | * @param OperationContextInterface|null $context |
||
993 | * @return RelationshipInterface[] |
||
994 | */ |
||
995 | public function getRelationships( |
||
1017 | 1 | ||
1018 | 1 | /** |
|
1019 | 1 | * Returns the repository info of the repository associated with this session. |
|
1020 | * |
||
1021 | * @return RepositoryInfoInterface the repository info |
||
1022 | */ |
||
1023 | public function getRepositoryInfo() |
||
1027 | 1 | ||
1028 | /** |
||
1029 | 1 | * Returns the repository id. |
|
1030 | * |
||
1031 | * @return string the repository id |
||
1032 | */ |
||
1033 | public function getRepositoryId() |
||
1037 | 1 | ||
1038 | /** |
||
1039 | 1 | * Gets the root folder of the repository with the given OperationContext. |
|
1040 | * |
||
1041 | * @param OperationContextInterface|null $context |
||
1042 | * @return FolderInterface the root folder object |
||
1043 | * @throws CmisRuntimeException |
||
1044 | */ |
||
1045 | public function getRootFolder(OperationContextInterface $context = null) |
||
1060 | |||
1061 | /** |
||
1062 | * Gets the type children of a type. |
||
1063 | * |
||
1064 | * @param string $typeId the type ID or <code>null</code> to request the base types |
||
1065 | * @param boolean $includePropertyDefinitions indicates whether the property definitions should be included or not |
||
1066 | * @return TypeDefinitionListInterface the type iterator |
||
1067 | * @throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist |
||
1068 | */ |
||
1069 | public function getTypeChildren($typeId, $includePropertyDefinitions) |
||
1079 | |||
1080 | /** |
||
1081 | * Gets the definition of a type. |
||
1082 | * |
||
1083 | * @param string $typeId the ID of the type |
||
1084 | * @param boolean $useCache specifies if the type definition should be first looked up in the type definition |
||
1085 | * cache, if it is set to <code>false</code> or the type definition is not in the cache, the type definition is |
||
1086 | * loaded from the repository |
||
1087 | * @return ObjectTypeInterface the type definition |
||
1088 | * @throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist |
||
1089 | */ |
||
1090 | public function getTypeDefinition($typeId, $useCache = true) |
||
1100 | |||
1101 | /** |
||
1102 | * Gets the type descendants of a type. |
||
1103 | * |
||
1104 | * @param string $typeId the type ID or <code>null</code> to request the base types |
||
1105 | * @param integer $depth indicates whether the property definitions should be included or not |
||
1106 | * @param boolean $includePropertyDefinitions the tree depth, must be greater than 0 or -1 for infinite depth |
||
1107 | * @return TypeDefinitionContainerInterface[] A tree that contains ObjectTypeInterface objects |
||
1108 | * @see ObjectTypeInterface ObjectTypeInterface contained in returned Tree |
||
1109 | * @throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist |
||
1110 | */ |
||
1111 | public function getTypeDescendants($typeId, $depth, $includePropertyDefinitions) |
||
1120 | |||
1121 | /** |
||
1122 | * Sends a query to the repository using the given OperationContext. (See CMIS spec "2.1.10 Query".) |
||
1123 | * |
||
1124 | * @param string $statement the query statement (CMIS query language) |
||
1125 | * @param boolean $searchAllVersions specifies whether non-latest document versions should be included or not, |
||
1126 | * <code>true</code> searches all document versions, <code>false</code> only searches latest document versions |
||
1127 | * @param OperationContextInterface|null $context the operation context to use |
||
1128 | * @return QueryResultInterface[] |
||
1129 | * @throws CmisInvalidArgumentException If statement is empty |
||
1130 | */ |
||
1131 | public function query($statement, $searchAllVersions = false, OperationContextInterface $context = null) |
||
1166 | |||
1167 | /** |
||
1168 | * Builds a CMIS query and returns the query results as an iterator of CmisObject objects. |
||
1169 | * |
||
1170 | * @param string $typeId the ID of the object type |
||
1171 | * @param string|null $where the WHERE part of the query |
||
1172 | * @param boolean $searchAllVersions specifies whether non-latest document versions should be included or not, |
||
1173 | * <code>true</code> searches all document versions, <code>false</code> only searches latest document versions |
||
1174 | * @param OperationContextInterface|null $context the operation context to use |
||
1175 | * @return CmisObjectInterface[] |
||
1176 | * @throws CmisInvalidArgumentException If type id is empty |
||
1177 | */ |
||
1178 | public function queryObjects( |
||
1238 | |||
1239 | /** |
||
1240 | * Removes the given object from the cache. |
||
1241 | * |
||
1242 | * Note about specific implementation: in order to avoid an over-engineered |
||
1243 | * taggable cache mechanism and with it, extensive traversal of objects when |
||
1244 | * creating tags, objects are not tagged in the cache. In addition, objects |
||
1245 | * are added to the cache with a secondary identification; the context - and |
||
1246 | * the context is not available here when removing a single object from the |
||
1247 | * cache. Instead, we opt to simply flush the entire cache and let it refill. |
||
1248 | * |
||
1249 | * @param ObjectIdInterface $objectId |
||
1250 | */ |
||
1251 | public function removeObjectFromCache(ObjectIdInterface $objectId) |
||
1255 | |||
1256 | /** |
||
1257 | * Removes a set of policies from an object. This operation is not atomic. |
||
1258 | * If it fails some policies might already be removed. |
||
1259 | * |
||
1260 | * @param ObjectIdInterface $objectId the ID the object |
||
1261 | * @param ObjectIdInterface[] $policyIds the IDs of the policies to be removed |
||
1262 | */ |
||
1263 | public function removePolicy(ObjectIdInterface $objectId, array $policyIds) |
||
1267 | |||
1268 | /** |
||
1269 | * Removes the direct ACEs of an object and sets the provided ACEs. |
||
1270 | * The changes are local to the given object and are not propagated to dependent objects. |
||
1271 | * |
||
1272 | * @param ObjectIdInterface $objectId |
||
1273 | * @param AceInterface[] $aces |
||
1274 | * @return AclInterface the new ACL of the object |
||
1275 | */ |
||
1276 | public function setAcl(ObjectIdInterface $objectId, array $aces) |
||
1280 | |||
1281 | /** |
||
1282 | * Sets the current session parameters for filtering, paging and caching. |
||
1283 | * |
||
1284 | * @param OperationContextInterface $context the OperationContext to be used for the session; |
||
1285 | * if null, a default context is used |
||
1286 | */ |
||
1287 | public function setDefaultContext(OperationContextInterface $context) |
||
1291 | |||
1292 | /** |
||
1293 | * Updates an existing type. |
||
1294 | * |
||
1295 | * @param TypeDefinitionInterface $type the type definition updates |
||
1296 | * @return ObjectTypeInterface the updated type definition |
||
1297 | */ |
||
1298 | public function updateType(TypeDefinitionInterface $type) |
||
1302 | |||
1303 | /** |
||
1304 | * Converts a type definition into an object type. If the object type is |
||
1305 | * cached, it returns the cached object. Otherwise it creates an object type |
||
1306 | * object and puts it into the cache. |
||
1307 | * |
||
1308 | * @param TypeDefinitionInterface $typeDefinition |
||
1309 | * @return ObjectTypeInterface |
||
1310 | */ |
||
1311 | private function convertTypeDefinition(TypeDefinitionInterface $typeDefinition) |
||
1316 | } |
||
1317 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.