Overview

Namespaces

  • NGS
    • Client
      • Exception
    • Converter
    • Patterns
  • PHP

Classes

  • AggregateDomainEvent
  • AggregateRoot
  • CubeBuilder
  • DomainEvent
  • GenericSearch
  • Identifiable
  • OlapCube
  • Repository
  • Search
  • Searchable
  • SearchBuilder
  • Snapshot
  • Specification
  • Templater

Interfaces

  • IDomainObject
  • IIdentifiable
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace NGS\Patterns;
 3: 
 4: require_once(__DIR__.'/IDomainObject.php');
 5: require_once(__DIR__.'/../Client/DomainProxy.php');
 6: 
 7: use NGS\Client\DomainProxy;
 8: use NGS\Name;
 9: 
10: /**
11:  * Search predicate which can be used to filter domain objects from the remote server.
12:  *
13:  * Specification is defined in DSL with keyword {@code specification}
14:  * and a predicate.
15:  * Server can convert specification to SQL query on the fly or call
16:  * database function created at compile time. Other optimization techniques
17:  * can be used too.
18:  *
19:  * DSL example:
20:  * <blockquote><pre>
21:  * module Todo {
22:  *   aggregate Task {
23:  *     timestamp createdOn;
24:  *     specification findBetween
25:  *     'it => it.createdOn >= after && it.createdOn <= before' {
26:  *       date after;
27:  *       date before;
28:  *     }
29:  *   }
30:  * }
31:  * </pre></blockquote>
32:  *
33:  */
34: abstract class Specification implements IDomainObject
35: {
36:     /**
37:      * Search domain object using conditions in specification
38:      *
39:      * @param type $limit
40:      * @param type $offset
41:      * @param array $order
42:      * @return array Array of found objects, or empty array if none found
43:      */
44:     public function search($limit = null, $offset = null, array $order = null)
45:     {
46:         $domainObject = Name::parent($this);
47:         return DomainProxy::instance()->searchWithSpecification($domainObject, $this, $limit, $offset, $order);
48:     }
49: 
50:     /**
51:      * Count domain object using conditions in specification
52:      *
53:      * @return type
54:      */
55:     public function count()
56:     {
57:         return DomainProxy::instance()->countWithSpecification($this);
58:     }
59: 
60:     /**
61:      * Creates an instance of SearchBuilder from specification.
62:      *
63:      * @see NGS\Patterns\SearchBuilder
64:      * @return \NGS\Patterns\SearchBuilder
65:      */
66:     public function builder()
67:     {
68:         return new SearchBuilder($this);
69:     }
70: }
71: 
API documentation generated by ApiGen 2.8.0