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__.'/../Client/DomainProxy.php');
 5: require_once(__DIR__.'/../Converter/PrimitiveConverter.php');
 6: 
 7: use NGS\Client\DomainProxy;
 8: use NGS\Converter\PrimitiveConverter;
 9: 
10: /**
11:  * DomainEvent which should be used when there is an action
12:  * to be applied on a single aggregate root.
13:  *
14:  * When {@see DomainEvent} affects only a single aggregate, then we can use
15:  * specialized aggregate domain event. This event can't have side effects outside
16:  * aggregate, which allows it to be replayed when it's asynchronous.
17:  * This is useful in write intensive scenarios to minimize write load in the database,
18:  * but will increase read load, because reading aggregate will have to read all it's
19:  * unapplied events and apply them during reconstruction.
20:  *
21:  * <p>
22:  * AggregateDomainEvent is defined in DSL with keyword {@code event}.
23:  * <blockquote><pre>
24:  * module Todo {
25:  *   aggregate Task;
26:  *   event&lt;Task&gt; MarkDone;
27:  * }
28:  * </pre></blockquote>
29:  */
30: abstract class AggregateDomainEvent
31: {
32:     /**
33:      * Applies event to aggregate root object
34:      *
35:      * @param \NGS\Patterns\AggregateRoot $value Aggregate instance on which
36:      * event will be applied
37:      * @return \NGS\Patterns\AggregateRoot Aggregate with updated values after
38:      * the event was executed
39:      * @throws \InvalidArgumentException
40:      */
41:     public function submit($value=null)
42:     {
43:         if ($value === null) {
44:             throw new \InvalidArgumentException("argument can't be null. It must be aggregate or it's uri");
45:         }
46:         if ($value instanceof AggregateRoot) {
47:             return  DomainProxy::instance()->submitAggregateEvent($this, $value->getURI());
48:         }
49:         return DomainProxy::instance()->submitAggregateEvent($this, PrimitiveConverter::toString($value));
50:     }
51: }
52: 
API documentation generated by ApiGen 2.8.0