File tree Expand file tree Collapse file tree 3 files changed +58
-2
lines changed
src/Application/Infrastructure/Type Expand file tree Collapse file tree 3 files changed +58
-2
lines changed Original file line number Diff line number Diff line change 88 *
99 */
1010return array (
11-
11+ 'service_manager ' => array (
12+ 'invokables ' => array (
13+ 'Doctrine\ORM\Mapping\UnderscoreNamingStrategy ' => 'Doctrine\ORM\Mapping\UnderscoreNamingStrategy ' ,
14+ ),
15+ 'aliases ' => array (
16+ 'entitymanager ' => 'doctrine.entitymanager.orm_default ' ,
17+ ),
18+ ),
19+ 'doctrine ' => array (
20+ 'configuration ' => array (
21+ 'orm_default ' => array (
22+ 'naming_strategy ' => 'Doctrine\ORM\Mapping\UnderscoreNamingStrategy '
23+ ),
24+ ),
25+ ),
1226);
Original file line number Diff line number Diff line change 9999 'orm_default ' => array (
100100 //Define custom doctrine types to map the ddd value objects
101101 'types ' => array (
102- 'uid ' => 'Application\Infrastructure\Type\UID ' ,
102+ 'uid ' => 'Application\Infrastructure\Type\UID ' ,
103+ 'trackingid ' => 'Application\Infrastructure\Type\TrackingId ' ,
103104 ),
104105 ),
105106 ),
Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ * This file is part of the codeliner/php-ddd-cargo-sample package.
4+ * (c) Alexander Miertsch <[email protected] > 5+ *
6+ * For the full copyright and license information, please view the LICENSE
7+ * file that was distributed with this source code.
8+ */
9+ namespace Application \Infrastrucure \Type ;
10+
11+ use Doctrine \DBAL \Types \TextType ;
12+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
13+ use Doctrine \DBAL \Types \ConversionException ;
14+ use Application \Domain \Model \Cargo \TrackingId as DomainTrackingId ;
15+ /**
16+ * Custom Doctrine Type UID
17+ *
18+ * @author Alexander Miertsch <[email protected] > 19+ */
20+ class TrackingId extends TextType
21+ {
22+ /**
23+ * {@inheritDoc}
24+ */
25+ public function convertToPHPValue ($ value , AbstractPlatform $ platform )
26+ {
27+ return new DomainTrackingId ($ value );
28+ }
29+
30+ /**
31+ * {@inheritDoc}
32+ */
33+ public function convertToDatabaseValue ($ value , AbstractPlatform $ platform )
34+ {
35+ if (!$ value instanceof DomainTrackingId) {
36+ throw ConversionException::conversionFailed ($ value , $ this ->getName ());
37+ }
38+
39+ return $ value ->toString ();
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments