Browse Source

Delete vendor/

Bastien Sevajol 11 years ago
parent
commit
3456a89d69
100 changed files with 0 additions and 21024 deletions
  1. 0 7
      vendor/autoload.php
  2. 0 1
      vendor/bin/doctrine
  3. 0 1
      vendor/bin/doctrine.php
  4. 0 46
      vendor/composer/autoload_real.php
  5. 0 2371
      vendor/composer/installed.json
  6. 0 55
      vendor/doctrine/common/lib/Doctrine/Common/Version.php
  7. 0 26
      vendor/doctrine/dbal/composer.json
  8. 0 927
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
  9. 0 183
      vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php
  10. 0 55
      vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php
  11. 0 245
      vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
  12. 0 252
      vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
  13. 0 8
      vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.travis.yml
  14. 0 32
      vendor/doctrine/orm/composer.json
  15. 0 59
      vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php
  16. 0 537
      vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
  17. 0 3050
      vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php
  18. 0 55
      vendor/doctrine/orm/lib/Doctrine/ORM/Version.php
  19. 0 464
      vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php
  20. 0 1098
      vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
  21. 0 142
      vendor/gedmo/doctrine-extensions/README.md
  22. 0 219
      vendor/gedmo/doctrine-extensions/doc/references.md
  23. 0 1265
      vendor/gedmo/doctrine-extensions/doc/tree.md
  24. 0 95
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Blameable/BlameableListener.php
  25. 0 25
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/Reference.php
  26. 0 21
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/ReferenceMany.php
  27. 0 21
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/ReferenceOne.php
  28. 0 31
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/TreePath.php
  29. 0 22
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/TreePathHash.php
  30. 0 215
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/LazyCollection.php
  31. 0 99
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Driver/Annotation.php
  32. 0 99
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/Adapter/ODM.php
  33. 0 98
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/Adapter/ORM.php
  34. 0 50
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/ReferencesAdapter.php
  35. 0 158
      vendor/gedmo/doctrine-extensions/lib/Gedmo/References/ReferencesListener.php
  36. 0 50
      vendor/gedmo/doctrine-extensions/lib/Gedmo/SoftDeleteable/Mapping/Validator.php
  37. 0 486
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php
  38. 0 83
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Annotation.php
  39. 0 99
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Xml.php
  40. 0 99
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Yaml.php
  41. 0 131
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Tool/Wrapper/EntityWrapper.php
  42. 0 745
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/TranslatableListener.php
  43. 0 250
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Annotation.php
  44. 0 197
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Yaml.php
  45. 0 230
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Validator.php
  46. 0 514
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Strategy/AbstractMaterializedPath.php
  47. 0 28
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorAlphanumeric.php
  48. 0 28
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorInterface.php
  49. 0 25
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorSha1.php
  50. 0 709
      vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/UploadableListener.php
  51. 0 1
      vendor/gedmo/doctrine-extensions/schemas/orm/doctrine-extensions-mapping.xsd
  52. 0 58
      vendor/gedmo/doctrine-extensions/tests/Gedmo/References/Fixture/ODM/MongoDB/Product.php
  53. 0 105
      vendor/gedmo/doctrine-extensions/tests/Gedmo/References/Fixture/ORM/StockItem.php
  54. 0 123
      vendor/gedmo/doctrine-extensions/tests/Gedmo/References/ReferencesListenerTest.php
  55. 0 331
      vendor/gedmo/doctrine-extensions/tests/Gedmo/Tool/BaseTestCaseOM.php
  56. 0 108
      vendor/gedmo/doctrine-extensions/tests/Gedmo/Tree/Fixture/MPFeaturesCategory.php
  57. 0 109
      vendor/gedmo/doctrine-extensions/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php
  58. 0 27
      vendor/gedmo/doctrine-extensions/tests/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorAlphanumericTest.php
  59. 0 698
      vendor/gedmo/doctrine-extensions/tests/Gedmo/Uploadable/UploadableEntityTest.php
  60. 0 62
      vendor/gedmo/doctrine-extensions/tests/bootstrap.php
  61. 0 66
      vendor/gedmo/doctrine-extensions/tests/phpunit.xml.dist
  62. 0 87
      vendor/jdorn/sql-formatter/README.md
  63. BIN
      vendor/jdorn/sql-formatter/examples/SqlFormatterExample.png
  64. 0 220
      vendor/jdorn/sql-formatter/examples/examples.php
  65. 0 705
      vendor/jdorn/sql-formatter/lib/SqlFormatter.php
  66. 0 44
      vendor/jdorn/sql-formatter/tests/performance.php
  67. 0 61
      vendor/jdorn/sql-formatter/tests/sql.sql
  68. 0 59
      vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/JMSSecurityExtraBundle.php
  69. 0 174
      vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/DoctrineParamConverter.php
  70. 0 221
      vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Tests/Request/ParamConverter/DoctrineParamConverterTest.php
  71. 0 27
      vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/composer.json
  72. 0 59
      vendor/sonata-project/exporter/lib/Exporter/Handler.php
  73. 0 25
      vendor/sonata-project/exporter/lib/Exporter/Source/ArraySourceIterator.php
  74. 0 91
      vendor/sonata-project/exporter/lib/Exporter/Source/ChainSourceIterator.php
  75. 0 94
      vendor/sonata-project/exporter/lib/Exporter/Source/DoctrineDBALConnectionSourceIterator.php
  76. 0 123
      vendor/sonata-project/exporter/lib/Exporter/Source/DoctrineODMQuerySourceIterator.php
  77. 0 81
      vendor/sonata-project/exporter/lib/Exporter/Source/PDOStatementSourceIterator.php
  78. 0 17
      vendor/sonata-project/exporter/lib/Exporter/Source/SourceIteratorInterface.php
  79. 0 86
      vendor/sonata-project/exporter/lib/Exporter/Source/SymfonySitemapSourceIterator.php
  80. 0 155
      vendor/sonata-project/exporter/lib/Exporter/Writer/GsaFeedWriter.php
  81. 0 49
      vendor/sonata-project/exporter/lib/Exporter/Writer/InMemoryWriter.php
  82. 0 367
      vendor/sonata-project/exporter/lib/Exporter/Writer/SitemapWriter.php
  83. 0 32
      vendor/sonata-project/exporter/lib/Exporter/Writer/WriterInterface.php
  84. 0 95
      vendor/sonata-project/exporter/lib/Exporter/Writer/XlsWriter.php
  85. 0 95
      vendor/sonata-project/exporter/lib/Exporter/Writer/XmlWriter.php
  86. 0 20
      vendor/sonata-project/exporter/test/Exporter/Test/Source/ChainSourceIteratorTest.php
  87. 0 161
      vendor/sonata-project/exporter/test/Exporter/Test/Writer/GsaFeedWriterTest.php
  88. 0 185
      vendor/sonata-project/exporter/test/Exporter/Test/Writer/SitemapWriterTest.php
  89. 0 12
      vendor/sonata-project/exporter/test/bootstrap.php
  90. 0 26
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/coffee.xml
  91. 0 51
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/compass.xml
  92. 0 36
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/cssembed.xml
  93. 0 20
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/dart.xml
  94. 0 22
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/gss.xml
  95. 0 28
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/handlebars.xml
  96. 0 24
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/jpegoptim.xml
  97. 0 28
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/jpegtran.xml
  98. 0 24
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/less.xml
  99. 0 26
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/lessphp.xml
  100. 0 0
      vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/optipng.xml

+ 0 - 7
vendor/autoload.php View File

@@ -1,7 +0,0 @@
1
-<?php
2
-
3
-// autoload.php generated by Composer
4
-
5
-require_once __DIR__ . '/composer' . '/autoload_real.php';
6
-
7
-return ComposerAutoloaderInit5c62f4434f25f02a2628d542287e27ca::getLoader();

+ 0 - 1
vendor/bin/doctrine View File

@@ -1 +0,0 @@
1
-../doctrine/orm/bin/doctrine

+ 0 - 1
vendor/bin/doctrine.php View File

@@ -1 +0,0 @@
1
-../doctrine/orm/bin/doctrine.php

+ 0 - 46
vendor/composer/autoload_real.php View File

@@ -1,46 +0,0 @@
1
-<?php
2
-
3
-// autoload_real.php generated by Composer
4
-
5
-class ComposerAutoloaderInit5c62f4434f25f02a2628d542287e27ca
6
-{
7
-    private static $loader;
8
-
9
-    public static function loadClassLoader($class)
10
-    {
11
-        if ('Composer\Autoload\ClassLoader' === $class) {
12
-            require __DIR__ . '/ClassLoader.php';
13
-        }
14
-    }
15
-
16
-    public static function getLoader()
17
-    {
18
-        if (null !== self::$loader) {
19
-            return self::$loader;
20
-        }
21
-
22
-        spl_autoload_register(array('ComposerAutoloaderInit5c62f4434f25f02a2628d542287e27ca', 'loadClassLoader'));
23
-        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
-        spl_autoload_unregister(array('ComposerAutoloaderInit5c62f4434f25f02a2628d542287e27ca', 'loadClassLoader'));
25
-
26
-        $vendorDir = dirname(__DIR__);
27
-        $baseDir = dirname($vendorDir);
28
-
29
-        $map = require __DIR__ . '/autoload_namespaces.php';
30
-        foreach ($map as $namespace => $path) {
31
-            $loader->add($namespace, $path);
32
-        }
33
-
34
-        $classMap = require __DIR__ . '/autoload_classmap.php';
35
-        if ($classMap) {
36
-            $loader->addClassMap($classMap);
37
-        }
38
-
39
-        $loader->register(true);
40
-
41
-        require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
42
-        require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
43
-
44
-        return $loader;
45
-    }
46
-}

File diff suppressed because it is too large
+ 0 - 2371
vendor/composer/installed.json


+ 0 - 55
vendor/doctrine/common/lib/Doctrine/Common/Version.php View File

@@ -1,55 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-namespace Doctrine\Common;
21
-
22
-/**
23
- * Class to store and retrieve the version of Doctrine
24
- *
25
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26
- * @link    www.doctrine-project.org
27
- * @since   2.0
28
- * @version $Revision$
29
- * @author  Benjamin Eberlei <kontakt@beberlei.de>
30
- * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
31
- * @author  Jonathan Wage <jonwage@gmail.com>
32
- * @author  Roman Borschel <roman@code-factory.org>
33
- */
34
-class Version
35
-{
36
-    /**
37
-     * Current Doctrine Version
38
-     */
39
-    const VERSION = '2.3.0';
40
-
41
-    /**
42
-     * Compares a Doctrine version with the current one.
43
-     *
44
-     * @param string $version Doctrine version to compare.
45
-     * @return int Returns -1 if older, 0 if it is the same, 1 if version
46
-     *             passed as argument is newer.
47
-     */
48
-    public static function compare($version)
49
-    {
50
-        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
51
-        $version = str_replace(' ', '', $version);
52
-
53
-        return version_compare($version, $currentVersion);
54
-    }
55
-}

+ 0 - 26
vendor/doctrine/dbal/composer.json View File

@@ -1,26 +0,0 @@
1
-{
2
-    "name": "doctrine/dbal",
3
-    "type": "library","version":"2.3.2",
4
-    "description": "Database Abstraction Layer",
5
-    "keywords": ["dbal", "database", "persistence", "queryobject"],
6
-    "homepage": "http://www.doctrine-project.org",
7
-    "license": "MIT",
8
-    "authors": [
9
-        {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
10
-        {"name": "Roman Borschel", "email": "roman@code-factory.org"},
11
-        {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
12
-        {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
13
-    ],
14
-    "require": {
15
-        "php": ">=5.3.2",
16
-        "doctrine/common": "2.3.*"
17
-    },
18
-    "autoload": {
19
-        "psr-0": { "Doctrine\\DBAL": "lib/" }
20
-    },
21
-    "extra": {
22
-        "branch-alias": {
23
-            "dev-master": "2.3.x-dev"
24
-        }
25
-    }
26
-}

+ 0 - 927
vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php View File

@@ -1,927 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
- *
16
- * This software consists of voluntary contributions made by many individuals
17
- * and is licensed under the MIT license. For more information, see
18
- * <http://www.doctrine-project.org>.
19
- */
20
-
21
-namespace Doctrine\DBAL\Platforms;
22
-
23
-use Doctrine\DBAL\Schema\TableDiff;
24
-use Doctrine\DBAL\DBALException;
25
-use Doctrine\DBAL\Schema\ForeignKeyConstraint;
26
-use Doctrine\DBAL\Schema\Index;
27
-use Doctrine\DBAL\Schema\Table;
28
-
29
-/**
30
- * The SQLServerPlatform provides the behavior, features and SQL dialect of the
31
- * Microsoft SQL Server database platform.
32
- *
33
- * @since 2.0
34
- * @author Roman Borschel <roman@code-factory.org>
35
- * @author Jonathan H. Wage <jonwage@gmail.com>
36
- * @author Benjamin Eberlei <kontakt@beberlei.de>
37
- */
38
-class SQLServerPlatform extends AbstractPlatform
39
-{
40
-    /**
41
-     * {@inheritDoc}
42
-     */
43
-    public function getDateDiffExpression($date1, $date2)
44
-    {
45
-        return 'DATEDIFF(day, ' . $date2 . ',' . $date1 . ')';
46
-    }
47
-
48
-    /**
49
-     * {@inheritDoc}
50
-     */
51
-    public function getDateAddDaysExpression($date, $days)
52
-    {
53
-        return 'DATEADD(day, ' . $days . ', ' . $date . ')';
54
-    }
55
-
56
-    /**
57
-     * {@inheritDoc}
58
-     */
59
-    public function getDateSubDaysExpression($date, $days)
60
-    {
61
-        return 'DATEADD(day, -1 * ' . $days . ', ' . $date . ')';
62
-    }
63
-
64
-    /**
65
-     * {@inheritDoc}
66
-     */
67
-    public function getDateAddMonthExpression($date, $months)
68
-    {
69
-        return 'DATEADD(month, ' . $months . ', ' . $date . ')';
70
-    }
71
-
72
-    /**
73
-     * {@inheritDoc}
74
-     */
75
-    public function getDateSubMonthExpression($date, $months)
76
-    {
77
-        return 'DATEADD(month, -1 * ' . $months . ', ' . $date . ')';
78
-    }
79
-
80
-    /**
81
-     * {@inheritDoc}
82
-     *
83
-     * MsSql prefers "autoincrement" identity columns since sequences can only
84
-     * be emulated with a table.
85
-     */
86
-    public function prefersIdentityColumns()
87
-    {
88
-        return true;
89
-    }
90
-
91
-    /**
92
-     * {@inheritDoc}
93
-     *
94
-     * MsSql supports this through AUTO_INCREMENT columns.
95
-     */
96
-    public function supportsIdentityColumns()
97
-    {
98
-        return true;
99
-    }
100
-
101
-    /**
102
-     * {@inheritDoc}
103
-     */
104
-    public function supportsReleaseSavepoints()
105
-    {
106
-        return false;
107
-    }
108
-
109
-    /**
110
-     * {@inheritDoc}
111
-     */
112
-    public function getCreateDatabaseSQL($name)
113
-    {
114
-        return 'CREATE DATABASE ' . $name;
115
-    }
116
-
117
-    /**
118
-     * {@inheritDoc}
119
-     */
120
-    public function getDropDatabaseSQL($name)
121
-    {
122
-        return 'DROP DATABASE ' . $name;
123
-    }
124
-
125
-    /**
126
-     * {@inheritDoc}
127
-     */
128
-    public function supportsCreateDropDatabase()
129
-    {
130
-        return false;
131
-    }
132
-
133
-    /**
134
-     * {@inheritDoc}
135
-     */
136
-    public function getDropForeignKeySQL($foreignKey, $table)
137
-    {
138
-        if ($foreignKey instanceof ForeignKeyConstraint) {
139
-            $foreignKey = $foreignKey->getQuotedName($this);
140
-        }
141
-
142
-        if ($table instanceof Table) {
143
-            $table = $table->getQuotedName($this);
144
-        }
145
-
146
-        return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $foreignKey;
147
-    }
148
-
149
-    /**
150
-     * {@inheritDoc}
151
-     */
152
-    public function getDropIndexSQL($index, $table = null)
153
-    {
154
-        if ($index instanceof Index) {
155
-            $index = $index->getQuotedName($this);
156
-        } else if (!is_string($index)) {
157
-            throw new \InvalidArgumentException('AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
158
-        }
159
-
160
-        if (!isset($table)) {
161
-            return 'DROP INDEX ' . $index;
162
-        }
163
-
164
-        if ($table instanceof Table) {
165
-            $table = $table->getQuotedName($this);
166
-        }
167
-
168
-        return "IF EXISTS (SELECT * FROM sysobjects WHERE name = '$index')
169
-                    ALTER TABLE " . $table . " DROP CONSTRAINT " . $index . "
170
-                ELSE
171
-                    DROP INDEX " . $index . " ON " . $table;
172
-    }
173
-
174
-    /**
175
-     * {@inheritDoc}
176
-     */
177
-    protected function _getCreateTableSQL($tableName, array $columns, array $options = array())
178
-    {
179
-        // @todo does other code breaks because of this?
180
-        // force primary keys to be not null
181
-        foreach ($columns as &$column) {
182
-            if (isset($column['primary']) && $column['primary']) {
183
-                $column['notnull'] = true;
184
-            }
185
-        }
186
-
187
-        $columnListSql = $this->getColumnDeclarationListSQL($columns);
188
-
189
-        if (isset($options['uniqueConstraints']) && !empty($options['uniqueConstraints'])) {
190
-            foreach ($options['uniqueConstraints'] as $name => $definition) {
191
-                $columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
192
-            }
193
-        }
194
-
195
-        if (isset($options['primary']) && !empty($options['primary'])) {
196
-            $flags = '';
197
-            if (isset($options['primary_index']) && $options['primary_index']->hasFlag('nonclustered')) {
198
-                $flags = ' NONCLUSTERED';
199
-            }
200
-            $columnListSql .= ', PRIMARY KEY' . $flags . ' (' . implode(', ', array_unique(array_values($options['primary']))) . ')';
201
-        }
202
-
203
-        $query = 'CREATE TABLE ' . $tableName . ' (' . $columnListSql;
204
-
205
-        $check = $this->getCheckDeclarationSQL($columns);
206
-        if (!empty($check)) {
207
-            $query .= ', ' . $check;
208
-        }
209
-        $query .= ')';
210
-
211
-        $sql[] = $query;
212
-
213
-        if (isset($options['indexes']) && !empty($options['indexes'])) {
214
-            foreach ($options['indexes'] as $index) {
215
-                $sql[] = $this->getCreateIndexSQL($index, $tableName);
216
-            }
217
-        }
218
-
219
-        if (isset($options['foreignKeys'])) {
220
-            foreach ((array) $options['foreignKeys'] as $definition) {
221
-                $sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
222
-            }
223
-        }
224
-
225
-        return $sql;
226
-    }
227
-
228
-    /**
229
-     * {@inheritDoc}
230
-     */
231
-    public function getCreatePrimaryKeySQL(Index $index, $table)
232
-    {
233
-        $flags = '';
234
-        if ($index->hasFlag('nonclustered')) {
235
-            $flags = ' NONCLUSTERED';
236
-        }
237
-        return 'ALTER TABLE ' . $table . ' ADD PRIMARY KEY' . $flags . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')';
238
-    }
239
-
240
-    /**
241
-     * {@inheritDoc}
242
-     */
243
-    public function getUniqueConstraintDeclarationSQL($name, Index $index)
244
-    {
245
-        $constraint = parent::getUniqueConstraintDeclarationSQL($name, $index);
246
-
247
-        $constraint = $this->_appendUniqueConstraintDefinition($constraint, $index);
248
-
249
-        return $constraint;
250
-    }
251
-
252
-    /**
253
-     * {@inheritDoc}
254
-     */
255
-    public function getCreateIndexSQL(Index $index, $table)
256
-    {
257
-        $constraint = parent::getCreateIndexSQL($index, $table);
258
-
259
-        if ($index->isUnique() && !$index->isPrimary()) {
260
-            $constraint = $this->_appendUniqueConstraintDefinition($constraint, $index);
261
-        }
262
-
263
-        return $constraint;
264
-    }
265
-
266
-    /**
267
-     * {@inheritDoc}
268
-     */
269
-    protected function getCreateIndexSQLFlags(Index $index)
270
-    {
271
-        $type = '';
272
-        if ($index->isUnique()) {
273
-            $type .= 'UNIQUE ';
274
-        }
275
-
276
-        if ($index->hasFlag('clustered')) {
277
-            $type .= 'CLUSTERED ';
278
-        } else if ($index->hasFlag('nonclustered')) {
279
-            $type .= 'NONCLUSTERED ';
280
-        }
281
-
282
-        return $type;
283
-    }
284
-
285
-    /**
286
-     * Extend unique key constraint with required filters
287
-     *
288
-     * @param string $sql
289
-     * @param Index $index
290
-     *
291
-     * @return string
292
-     */
293
-    private function _appendUniqueConstraintDefinition($sql, Index $index)
294
-    {
295
-        $fields = array();
296
-        foreach ($index->getColumns() as $field => $definition) {
297
-            if (!is_array($definition)) {
298
-                $field = $definition;
299
-            }
300
-
301
-            $fields[] = $field . ' IS NOT NULL';
302
-        }
303
-
304
-        return $sql . ' WHERE ' . implode(' AND ', $fields);
305
-    }
306
-
307
-    /**
308
-     * {@inheritDoc}
309
-     */
310
-    public function getAlterTableSQL(TableDiff $diff)
311
-    {
312
-        $queryParts = array();
313
-        $sql = array();
314
-        $columnSql = array();
315
-
316
-        foreach ($diff->addedColumns as $column) {
317
-            if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
318
-                continue;
319
-            }
320
-
321
-            $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
322
-        }
323
-
324
-        foreach ($diff->removedColumns as $column) {
325
-            if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
326
-                continue;
327
-            }
328
-
329
-            $queryParts[] = 'DROP COLUMN ' . $column->getQuotedName($this);
330
-        }
331
-
332
-        foreach ($diff->changedColumns as $columnDiff) {
333
-            if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
334
-                continue;
335
-            }
336
-
337
-            /* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
338
-            $column = $columnDiff->column;
339
-            $queryParts[] = 'ALTER COLUMN ' .
340
-                    $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
341
-        }
342
-
343
-        foreach ($diff->renamedColumns as $oldColumnName => $column) {
344
-            if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
345
-                continue;
346
-            }
347
-
348
-            $sql[] = "sp_RENAME '". $diff->name. ".". $oldColumnName . "' , '".$column->getQuotedName($this)."', 'COLUMN'";
349
-            $queryParts[] = 'ALTER COLUMN ' .
350
-                    $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
351
-        }
352
-
353
-        $tableSql = array();
354
-
355
-        if ($this->onSchemaAlterTable($diff, $tableSql)) {
356
-            return array_merge($tableSql, $columnSql);
357
-        }
358
-
359
-        foreach ($queryParts as $query) {
360
-            $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
361
-        }
362
-
363
-        $sql = array_merge($sql, $this->_getAlterTableIndexForeignKeySQL($diff));
364
-
365
-        if ($diff->newName !== false) {
366
-            $sql[] = "sp_RENAME '" . $diff->name . "', '" . $diff->newName . "'";
367
-        }
368
-
369
-        return array_merge($sql, $tableSql, $columnSql);
370
-    }
371
-
372
-    /**
373
-     * {@inheritDoc}
374
-     */
375
-    public function getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName)
376
-    {
377
-        return 'INSERT INTO ' . $quotedTableName . ' DEFAULT VALUES';
378
-    }
379
-
380
-    /**
381
-     * {@inheritDoc}
382
-     */
383
-    public function getShowDatabasesSQL()
384
-    {
385
-        return 'SHOW DATABASES';
386
-    }
387
-
388
-    /**
389
-     * {@inheritDoc}
390
-     */
391
-    public function getListTablesSQL()
392
-    {
393
-        // "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams
394
-        return "SELECT name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' ORDER BY name";
395
-    }
396
-
397
-    /**
398
-     * {@inheritDoc}
399
-     */
400
-    public function getListTableColumnsSQL($table, $database = null)
401
-    {
402
-        return "exec sp_columns @table_name = '" . $table . "'";
403
-    }
404
-
405
-    /**
406
-     * {@inheritDoc}
407
-     */
408
-    public function getListTableForeignKeysSQL($table, $database = null)
409
-    {
410
-        return "SELECT f.name AS ForeignKey,
411
-                SCHEMA_NAME (f.SCHEMA_ID) AS SchemaName,
412
-                OBJECT_NAME (f.parent_object_id) AS TableName,
413
-                COL_NAME (fc.parent_object_id,fc.parent_column_id) AS ColumnName,
414
-                SCHEMA_NAME (o.SCHEMA_ID) ReferenceSchemaName,
415
-                OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
416
-                COL_NAME(fc.referenced_object_id,fc.referenced_column_id) AS ReferenceColumnName,
417
-                f.delete_referential_action_desc,
418
-                f.update_referential_action_desc
419
-                FROM sys.foreign_keys AS f
420
-                INNER JOIN sys.foreign_key_columns AS fc
421
-                INNER JOIN sys.objects AS o ON o.OBJECT_ID = fc.referenced_object_id
422
-                ON f.OBJECT_ID = fc.constraint_object_id
423
-                WHERE OBJECT_NAME (f.parent_object_id) = '" . $table . "'";
424
-    }
425
-
426
-    /**
427
-     * {@inheritDoc}
428
-     */
429
-    public function getListTableIndexesSQL($table, $currentDatabase = null)
430
-    {
431
-        return "exec sp_helpindex '" . $table . "'";
432
-    }
433
-
434
-    /**
435
-     * {@inheritDoc}
436
-     */
437
-    public function getCreateViewSQL($name, $sql)
438
-    {
439
-        return 'CREATE VIEW ' . $name . ' AS ' . $sql;
440
-    }
441
-
442
-    /**
443
-     * {@inheritDoc}
444
-     */
445
-    public function getListViewsSQL($database)
446
-    {
447
-        return "SELECT name FROM sysobjects WHERE type = 'V' ORDER BY name";
448
-    }
449
-
450
-    /**
451
-     * {@inheritDoc}
452
-     */
453
-    public function getDropViewSQL($name)
454
-    {
455
-        return 'DROP VIEW ' . $name;
456
-    }
457
-
458
-    /**
459
-     * {@inheritDoc}
460
-     */
461
-    public function getRegexpExpression()
462
-    {
463
-        return 'RLIKE';
464
-    }
465
-
466
-    /**
467
-     * {@inheritDoc}
468
-     */
469
-    public function getGuidExpression()
470
-    {
471
-        return 'UUID()';
472
-    }
473
-
474
-    /**
475
-     * {@inheritDoc}
476
-     */
477
-    public function getLocateExpression($str, $substr, $startPos = false)
478
-    {
479
-        if ($startPos == false) {
480
-            return 'CHARINDEX(' . $substr . ', ' . $str . ')';
481
-        }
482
-
483
-        return 'CHARINDEX(' . $substr . ', ' . $str . ', ' . $startPos . ')';
484
-    }
485
-
486
-    /**
487
-     * {@inheritDoc}
488
-     */
489
-    public function getModExpression($expression1, $expression2)
490
-    {
491
-        return $expression1 . ' % ' . $expression2;
492
-    }
493
-
494
-    /**
495
-     * {@inheritDoc}
496
-     */
497
-    public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false)
498
-    {
499
-        if ( ! $char) {
500
-            switch ($pos) {
501
-                case self::TRIM_LEADING:
502
-                    $trimFn = 'LTRIM';
503
-                    break;
504
-
505
-                case self::TRIM_TRAILING:
506
-                    $trimFn = 'RTRIM';
507
-                    break;
508
-
509
-                default:
510
-                    return 'LTRIM(RTRIM(' . $str . '))';
511
-            }
512
-
513
-            return $trimFn . '(' . $str . ')';
514
-        }
515
-
516
-        /** Original query used to get those expressions
517
-          declare @c varchar(100) = 'xxxBarxxx', @trim_char char(1) = 'x';
518
-          declare @pat varchar(10) = '%[^' + @trim_char + ']%';
519
-          select @c as string
520
-          , @trim_char as trim_char
521
-          , stuff(@c, 1, patindex(@pat, @c) - 1, null) as trim_leading
522
-          , reverse(stuff(reverse(@c), 1, patindex(@pat, reverse(@c)) - 1, null)) as trim_trailing
523
-          , reverse(stuff(reverse(stuff(@c, 1, patindex(@pat, @c) - 1, null)), 1, patindex(@pat, reverse(stuff(@c, 1, patindex(@pat, @c) - 1, null))) - 1, null)) as trim_both;
524
-         */
525
-        $pattern = "'%[^' + $char + ']%'";
526
-
527
-        if ($pos == self::TRIM_LEADING) {
528
-            return 'stuff(' . $str . ', 1, patindex(' . $pattern . ', ' . $str . ') - 1, null)';
529
-        }
530
-
531
-        if ($pos == self::TRIM_TRAILING) {
532
-            return 'reverse(stuff(reverse(' . $str . '), 1, patindex(' . $pattern . ', reverse(' . $str . ')) - 1, null))';
533
-        }
534
-
535
-        return 'reverse(stuff(reverse(stuff(' . $str . ', 1, patindex(' . $pattern . ', ' . $str . ') - 1, null)), 1, patindex(' . $pattern . ', reverse(stuff(' . $str . ', 1, patindex(' . $pattern . ', ' . $str . ') - 1, null))) - 1, null))';
536
-    }
537
-
538
-    /**
539
-     * {@inheritDoc}
540
-     */
541
-    public function getConcatExpression()
542
-    {
543
-        $args = func_get_args();
544
-
545
-        return '(' . implode(' + ', $args) . ')';
546
-    }
547
-
548
-    public function getListDatabasesSQL()
549
-    {
550
-        return 'SELECT * FROM SYS.DATABASES';
551
-    }
552
-
553
-    /**
554
-     * {@inheritDoc}
555
-     */
556
-    public function getSubstringExpression($value, $from, $length = null)
557
-    {
558
-        if (!is_null($length)) {
559
-            return 'SUBSTRING(' . $value . ', ' . $from . ', ' . $length . ')';
560
-        }
561
-
562
-        return 'SUBSTRING(' . $value . ', ' . $from . ', LEN(' . $value . ') - ' . $from . ' + 1)';
563
-    }
564
-
565
-    /**
566
-     * {@inheritDoc}
567
-     */
568
-    public function getLengthExpression($column)
569
-    {
570
-        return 'LEN(' . $column . ')';
571
-    }
572
-
573
-    /**
574
-     * {@inheritDoc}
575
-     */
576
-    public function getSetTransactionIsolationSQL($level)
577
-    {
578
-        return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
579
-    }
580
-
581
-    /**
582
-     * {@inheritDoc}
583
-     */
584
-    public function getIntegerTypeDeclarationSQL(array $field)
585
-    {
586
-        return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
587
-    }
588
-
589
-    /**
590
-     * {@inheritDoc}
591
-     */
592
-    public function getBigIntTypeDeclarationSQL(array $field)
593
-    {
594
-        return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
595
-    }
596
-
597
-    /**
598
-     * {@inheritDoc}
599
-     */
600
-    public function getSmallIntTypeDeclarationSQL(array $field)
601
-    {
602
-        return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
603
-    }
604
-
605
-    /**
606
-     * {@inheritDoc}
607
-     */
608
-    public function getGuidTypeDeclarationSQL(array $field)
609
-    {
610
-        return 'UNIQUEIDENTIFIER';
611
-    }
612
-
613
-    /**
614
-     * {@inheritDoc}
615
-     */
616
-    protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
617
-    {
618
-        return $fixed ? ($length ? 'NCHAR(' . $length . ')' : 'CHAR(255)') : ($length ? 'NVARCHAR(' . $length . ')' : 'NVARCHAR(255)');
619
-    }
620
-
621
-    /**
622
-     * {@inheritDoc}
623
-     */
624
-    public function getClobTypeDeclarationSQL(array $field)
625
-    {
626
-        return 'TEXT';
627
-    }
628
-
629
-    /**
630
-     * {@inheritDoc}
631
-     */
632
-    protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
633
-    {
634
-        return (!empty($columnDef['autoincrement'])) ? ' IDENTITY' : '';
635
-    }
636
-
637
-    /**
638
-     * {@inheritDoc}
639
-     */
640
-    public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
641
-    {
642
-        return 'DATETIME';
643
-    }
644
-
645
-    /**
646
-     * {@inheritDoc}
647
-     */
648
-    public function getDateTypeDeclarationSQL(array $fieldDeclaration)
649
-    {
650
-        return 'DATETIME';
651
-    }
652
-
653
-    /**
654
-     * {@inheritDoc}
655
-     */
656
-    public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
657
-    {
658
-        return 'DATETIME';
659
-    }
660
-
661
-    /**
662
-     * {@inheritDoc}
663
-     */
664
-    public function getBooleanTypeDeclarationSQL(array $field)
665
-    {
666
-        return 'BIT';
667
-    }
668
-
669
-    /**
670
-     * {@inheritDoc}
671
-     *
672
-     * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
673
-     */
674
-    protected function doModifyLimitQuery($query, $limit, $offset = null)
675
-    {
676
-        if ($limit > 0) {
677
-            if ($offset == 0) {
678
-                $query = preg_replace('/^(SELECT\s(DISTINCT\s)?)/i', '\1TOP ' . $limit . ' ', $query);
679
-            } else {
680
-                $orderby = stristr($query, 'ORDER BY');
681
-
682
-                if ( ! $orderby) {
683
-                    $over = 'ORDER BY (SELECT 0)';
684
-                } else {
685
-                    $over = preg_replace('/\"[^,]*\".\"([^,]*)\"/i', '"inner_tbl"."$1"', $orderby);
686
-                }
687
-
688
-                // Remove ORDER BY clause from $query
689
-                $query = preg_replace('/\s+ORDER BY(.*)/', '', $query);
690
-                $query = preg_replace('/^SELECT\s/', '', $query);
691
-
692
-                $start = $offset + 1;
693
-                $end = $offset + $limit;
694
-
695
-                $query = "SELECT * FROM (SELECT ROW_NUMBER() OVER ($over) AS doctrine_rownum, $query) AS doctrine_tbl WHERE doctrine_rownum BETWEEN $start AND $end";
696
-            }
697
-        }
698
-
699
-        return $query;
700
-    }
701
-
702
-    /**
703
-     * {@inheritDoc}
704
-     */
705
-    public function supportsLimitOffset()
706
-    {
707
-        return false;
708
-    }
709
-
710
-    /**
711
-     * {@inheritDoc}
712
-     */
713
-    public function convertBooleans($item)
714
-    {
715
-        if (is_array($item)) {
716
-            foreach ($item as $key => $value) {
717
-                if (is_bool($value) || is_numeric($item)) {
718
-                    $item[$key] = ($value) ? 1 : 0;
719
-                }
720
-            }
721
-        } else if (is_bool($item) || is_numeric($item)) {
722
-            $item = ($item) ? 1 : 0;
723
-        }
724
-
725
-        return $item;
726
-    }
727
-
728
-    /**
729
-     * {@inheritDoc}
730
-     */
731
-    public function getCreateTemporaryTableSnippetSQL()
732
-    {
733
-        return "CREATE TABLE";
734
-    }
735
-
736
-    /**
737
-     * {@inheritDoc}
738
-     */
739
-    public function getTemporaryTableName($tableName)
740
-    {
741
-        return '#' . $tableName;
742
-    }
743
-
744
-    /**
745
-     * {@inheritDoc}
746
-     */
747
-    public function getDateTimeFormatString()
748
-    {
749
-        return 'Y-m-d H:i:s.000';
750
-    }
751
-
752
-    /**
753
-     * {@inheritDoc}
754
-     */
755
-    public function getDateFormatString()
756
-    {
757
-        return 'Y-m-d H:i:s.000';
758
-    }
759
-
760
-    /**
761
-     * {@inheritDoc}
762
-     */
763
-    public function getTimeFormatString()
764
-    {
765
-        return 'Y-m-d H:i:s.000';
766
-    }
767
-
768
-    /**
769
-     * {@inheritDoc}
770
-     */
771
-    public function getDateTimeTzFormatString()
772
-    {
773
-        return $this->getDateTimeFormatString();
774
-    }
775
-
776
-    /**
777
-     * {@inheritDoc}
778
-     */
779
-    public function getName()
780
-    {
781
-        return 'mssql';
782
-    }
783
-
784
-    /**
785
-     * {@inheritDoc}
786
-     */
787
-    protected function initializeDoctrineTypeMappings()
788
-    {
789
-        $this->doctrineTypeMapping = array(
790
-            'bigint' => 'bigint',
791
-            'numeric' => 'decimal',
792
-            'bit' => 'boolean',
793
-            'smallint' => 'smallint',
794
-            'decimal' => 'decimal',
795
-            'smallmoney' => 'integer',
796
-            'int' => 'integer',
797
-            'tinyint' => 'smallint',
798
-            'money' => 'integer',
799
-            'float' => 'float',
800
-            'real' => 'float',
801
-            'double' => 'float',
802
-            'double precision' => 'float',
803
-            'datetimeoffset' => 'datetimetz',
804
-            'smalldatetime' => 'datetime',
805
-            'datetime' => 'datetime',
806
-            'char' => 'string',
807
-            'varchar' => 'string',
808
-            'text' => 'text',
809
-            'nchar' => 'string',
810
-            'nvarchar' => 'string',
811
-            'ntext' => 'text',
812
-            'binary' => 'text',
813
-            'varbinary' => 'blob',
814
-            'image' => 'text',
815
-            'uniqueidentifier' => 'guid',
816
-        );
817
-    }
818
-
819
-    /**
820
-     * {@inheritDoc}
821
-     */
822
-    public function createSavePoint($savepoint)
823
-    {
824
-        return 'SAVE TRANSACTION ' . $savepoint;
825
-    }
826
-
827
-    /**
828
-     * {@inheritDoc}
829
-     */
830
-    public function releaseSavePoint($savepoint)
831
-    {
832
-        return '';
833
-    }
834
-
835
-    /**
836
-     * {@inheritDoc}
837
-     */
838
-    public function rollbackSavePoint($savepoint)
839
-    {
840
-        return 'ROLLBACK TRANSACTION ' . $savepoint;
841
-    }
842
-
843
-    /**
844
-     * {@inheritDoc}
845
-     */
846
-    public function appendLockHint($fromClause, $lockMode)
847
-    {
848
-        // @todo coorect
849
-        if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
850
-            return $fromClause . ' WITH (tablockx)';
851
-        }
852
-
853
-        if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
854
-            return $fromClause . ' WITH (tablockx)';
855
-        }
856
-
857
-        return $fromClause;
858
-    }
859
-
860
-    /**
861
-     * {@inheritDoc}
862
-     */
863
-    public function getForUpdateSQL()
864
-    {
865
-        return ' ';
866
-    }
867
-
868
-    /**
869
-     * {@inheritDoc}
870
-     */
871
-    protected function getReservedKeywordsClass()
872
-    {
873
-        return 'Doctrine\DBAL\Platforms\Keywords\MsSQLKeywords';
874
-    }
875
-
876
-    /**
877
-     * {@inheritDoc}
878
-     */
879
-    public function quoteSingleIdentifier($str)
880
-    {
881
-        return "[" . str_replace("]", "][", $str) . "]";
882
-    }
883
-
884
-    /**
885
-     * {@inheritDoc}
886
-     */
887
-    public function getTruncateTableSQL($tableName, $cascade = false)
888
-    {
889
-        return 'TRUNCATE TABLE '.$tableName;
890
-    }
891
-
892
-    /**
893
-     * {@inheritDoc}
894
-     */
895
-    public function getBlobTypeDeclarationSQL(array $field)
896
-    {
897
-        return 'VARBINARY(MAX)';
898
-    }
899
-
900
-    /**
901
-     * {@inheritDoc}
902
-     */
903
-    public function getDefaultValueDeclarationSQL($field)
904
-    {
905
-        if ( ! isset($field['default'])) {
906
-            return empty($field['notnull']) ? ' NULL' : '';
907
-        }
908
-
909
-        if ( ! isset($field['type'])) {
910
-            return " DEFAULT '" . $field['default'] . "'";
911
-        }
912
-
913
-        if (in_array((string) $field['type'], array('Integer', 'BigInteger', 'SmallInteger'))) {
914
-            return " DEFAULT " . $field['default'];
915
-        }
916
-
917
-        if ((string) $field['type'] == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL()) {
918
-            return " DEFAULT " . $this->getCurrentTimestampSQL();
919
-        }
920
-
921
-        if ((string) $field['type'] == 'Boolean') {
922
-            return " DEFAULT '" . $this->convertBooleans($field['default']) . "'";
923
-        }
924
-
925
-        return " DEFAULT '" . $field['default'] . "'";
926
-    }
927
-}

+ 0 - 183
vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php View File

@@ -1,183 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-
21
-namespace Doctrine\DBAL;
22
-
23
-use Doctrine\DBAL\Connection;
24
-
25
-/**
26
- * Utility class that parses sql statements with regard to types and parameters.
27
- *
28
- * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
29
- * @link        www.doctrine-project.com
30
- * @since       2.0
31
- * @author      Benjamin Eberlei <kontakt@beberlei.de>
32
- */
33
-class SQLParserUtils
34
-{
35
-    /**
36
-     * Get an array of the placeholders in an sql statements as keys and their positions in the query string.
37
-     *
38
-     * Returns an integer => integer pair (indexed from zero) for a positional statement
39
-     * and a string => int[] pair for a named statement.
40
-     *
41
-     * @param string $statement
42
-     * @param bool $isPositional
43
-     * @return array
44
-     */
45
-    static public function getPlaceholderPositions($statement, $isPositional = true)
46
-    {
47
-        $match = ($isPositional) ? '?' : ':';
48
-        if (strpos($statement, $match) === false) {
49
-            return array();
50
-        }
51
-
52
-        $count = 0;
53
-        $inLiteral = false; // a valid query never starts with quotes
54
-        $stmtLen = strlen($statement);
55
-        $paramMap = array();
56
-        for ($i = 0; $i < $stmtLen; $i++) {
57
-            if ($statement[$i] == $match && !$inLiteral && ($isPositional || $statement[$i+1] != '=')) {
58
-                // real positional parameter detected
59
-                if ($isPositional) {
60
-                    $paramMap[$count] = $i;
61
-                } else {
62
-                    $name = "";
63
-                    // TODO: Something faster/better to match this than regex?
64
-                    for ($j = $i + 1; ($j < $stmtLen && preg_match('(([a-zA-Z0-9_]{1}))', $statement[$j])); $j++) {
65
-                        $name .= $statement[$j];
66
-                    }
67
-                    $paramMap[$i] = $name; // named parameters can be duplicated!
68
-                    $i = $j;
69
-                }
70
-                ++$count;
71
-            } else if ($statement[$i] == "'" || $statement[$i] == '"') {
72
-                $inLiteral = ! $inLiteral; // switch state!
73
-            }
74
-        }
75
-
76
-        return $paramMap;
77
-    }
78
-
79
-    /**
80
-     * For a positional query this method can rewrite the sql statement with regard to array parameters.
81
-     *
82
-     * @param string    $query  The SQL query to execute.
83
-     * @param array     $params The parameters to bind to the query.
84
-     * @param array     $types  The types the previous parameters are in.
85
-     * 
86
-     * @return array
87
-     */
88
-    static public function expandListParameters($query, $params, $types)
89
-    {
90
-        $isPositional   = is_int(key($params));
91
-        $arrayPositions = array();
92
-        $bindIndex      = -1;
93
-
94
-        foreach ($types as $name => $type) {
95
-            ++$bindIndex;
96
-
97
-            if ($type !== Connection::PARAM_INT_ARRAY && $type !== Connection::PARAM_STR_ARRAY) {
98
-                continue;
99
-            }
100
-
101
-            if ($isPositional) {
102
-                $name = $bindIndex;
103
-            }
104
-
105
-            $arrayPositions[$name] = false;
106
-        }
107
-
108
-        if (( ! $arrayPositions && $isPositional) || (count($params) != count($types))) {
109
-            return array($query, $params, $types);
110
-        }
111
-
112
-        $paramPos = self::getPlaceholderPositions($query, $isPositional);
113
-
114
-        if ($isPositional) {
115
-            $paramOffset = 0;
116
-            $queryOffset = 0;
117
-
118
-            foreach ($paramPos as $needle => $needlePos) {
119
-                if ( ! isset($arrayPositions[$needle])) {
120
-                    continue;
121
-                }
122
-
123
-                $needle    += $paramOffset;
124
-                $needlePos += $queryOffset;
125
-                $count      = count($params[$needle]);
126
-
127
-                $params = array_merge(
128
-                    array_slice($params, 0, $needle),
129
-                    $params[$needle],
130
-                    array_slice($params, $needle + 1)
131
-                );
132
-
133
-                $types = array_merge(
134
-                    array_slice($types, 0, $needle),
135
-                    array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET), // array needles are at PDO::PARAM_* + 100
136
-                    array_slice($types, $needle + 1)
137
-                );
138
-
139
-                $expandStr  = implode(", ", array_fill(0, $count, "?"));
140
-                $query      = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
141
-
142
-                $paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle.
143
-                $queryOffset += (strlen($expandStr) - 1);
144
-            }
145
-
146
-            return array($query, $params, $types);
147
-        }
148
-
149
-
150
-        $queryOffset = 0;
151
-        $typesOrd    = array();
152
-        $paramsOrd   = array();
153
-
154
-        foreach ($paramPos as $pos => $paramName) {
155
-            $paramLen   = strlen($paramName) + 1;
156
-            $value      = $params[$paramName];
157
-
158
-            if ( ! isset($arrayPositions[$paramName])) {
159
-                $pos         += $queryOffset;
160
-                $queryOffset -= ($paramLen - 1);
161
-                $paramsOrd[]  = $value;
162
-                $typesOrd[]   = $types[$paramName];
163
-                $query        = substr($query, 0, $pos) . '?' . substr($query, ($pos + $paramLen));
164
-            
165
-                continue;
166
-            }
167
-
168
-            $count      = count($value);
169
-            $expandStr  = $count > 0 ? implode(', ', array_fill(0, $count, '?')) : '?';
170
-
171
-            foreach ($value as $val) {
172
-                $paramsOrd[] = $val;
173
-                $typesOrd[]  = $types[$paramName] - Connection::ARRAY_PARAM_OFFSET;
174
-            }
175
-
176
-            $pos         += $queryOffset;
177
-            $queryOffset += (strlen($expandStr) - $paramLen);
178
-            $query        = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen));
179
-        }
180
-
181
-        return array($query, $paramsOrd, $typesOrd);
182
-    }
183
-}

+ 0 - 55
vendor/doctrine/dbal/lib/Doctrine/DBAL/Version.php View File

@@ -1,55 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-namespace Doctrine\DBAL;
21
-
22
-/**
23
- * Class to store and retrieve the version of Doctrine
24
- *
25
- * 
26
- * @link    www.doctrine-project.org
27
- * @since   2.0
28
- * @version $Revision$
29
- * @author  Benjamin Eberlei <kontakt@beberlei.de>
30
- * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
31
- * @author  Jonathan Wage <jonwage@gmail.com>
32
- * @author  Roman Borschel <roman@code-factory.org>
33
- */
34
-class Version
35
-{
36
-    /**
37
-     * Current Doctrine Version
38
-     */
39
-    const VERSION = '2.3.2';
40
-
41
-    /**
42
-     * Compares a Doctrine version with the current one.
43
-     *
44
-     * @param string $version Doctrine version to compare.
45
-     * @return int Returns -1 if older, 0 if it is the same, 1 if version
46
-     *             passed as argument is newer.
47
-     */
48
-    public static function compare($version)
49
-    {
50
-        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
51
-        $version = str_replace(' ', '', $version);
52
-
53
-        return version_compare($version, $currentVersion);
54
-    }
55
-}

+ 0 - 245
vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php View File

@@ -1,245 +0,0 @@
1
-<?php
2
-
3
-namespace Doctrine\Tests\DBAL\Platforms;
4
-
5
-use Doctrine\DBAL\Platforms\SQLServer2008Platform;
6
-use Doctrine\DBAL\Types\Type;
7
-
8
-class SQLServerPlatformTest extends AbstractPlatformTestCase
9
-{
10
-    public function createPlatform()
11
-    {
12
-        return new SQLServer2008Platform;
13
-    }
14
-
15
-    public function getGenerateTableSql()
16
-    {
17
-        return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255) NULL, PRIMARY KEY (id))';
18
-    }
19
-
20
-    public function getGenerateTableWithMultiColumnUniqueIndexSql()
21
-    {
22
-        return array(
23
-            'CREATE TABLE test (foo NVARCHAR(255) NULL, bar NVARCHAR(255) NULL)',
24
-            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar) WHERE foo IS NOT NULL AND bar IS NOT NULL'
25
-        );
26
-    }
27
-
28
-    public function getGenerateAlterTableSql()
29
-    {
30
-        return array(
31
-            'ALTER TABLE mytable ADD quota INT NULL',
32
-            'ALTER TABLE mytable DROP COLUMN foo',
33
-            'ALTER TABLE mytable ALTER COLUMN baz NVARCHAR(255) DEFAULT \'def\' NOT NULL',
34
-            'ALTER TABLE mytable ALTER COLUMN bloo BIT DEFAULT \'0\' NOT NULL',
35
-            "sp_RENAME 'mytable', 'userlist'",
36
-        );
37
-    }
38
-
39
-    public function testGeneratesSqlSnippets()
40
-    {
41
-        $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
42
-        $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
43
-        $this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
44
-    }
45
-
46
-    public function testGeneratesTransactionsCommands()
47
-    {
48
-        $this->assertEquals(
49
-                'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
50
-                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
51
-        );
52
-        $this->assertEquals(
53
-                'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
54
-                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
55
-        );
56
-        $this->assertEquals(
57
-                'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ',
58
-                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
59
-        );
60
-        $this->assertEquals(
61
-                'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
62
-                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
63
-        );
64
-    }
65
-
66
-    public function testGeneratesDDLSnippets()
67
-    {
68
-        $dropDatabaseExpectation = 'DROP DATABASE foobar';
69
-
70
-        $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
71
-        $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
72
-        $this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar'));
73
-        $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
74
-    }
75
-
76
-    public function testGeneratesTypeDeclarationForIntegers()
77
-    {
78
-        $this->assertEquals(
79
-                'INT',
80
-                $this->_platform->getIntegerTypeDeclarationSQL(array())
81
-        );
82
-        $this->assertEquals(
83
-                'INT IDENTITY',
84
-                $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
85
-        ));
86
-        $this->assertEquals(
87
-                'INT IDENTITY',
88
-                $this->_platform->getIntegerTypeDeclarationSQL(
89
-                        array('autoincrement' => true, 'primary' => true)
90
-        ));
91
-    }
92
-
93
-    public function testGeneratesTypeDeclarationsForStrings()
94
-    {
95
-        $this->assertEquals(
96
-                'NCHAR(10)',
97
-                $this->_platform->getVarcharTypeDeclarationSQL(
98
-                        array('length' => 10, 'fixed' => true)
99
-        ));
100
-        $this->assertEquals(
101
-                'NVARCHAR(50)',
102
-                $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
103
-                'Variable string declaration is not correct'
104
-        );
105
-        $this->assertEquals(
106
-                'NVARCHAR(255)',
107
-                $this->_platform->getVarcharTypeDeclarationSQL(array()),
108
-                'Long string declaration is not correct'
109
-        );
110
-    }
111
-
112
-    public function testPrefersIdentityColumns()
113
-    {
114
-        $this->assertTrue($this->_platform->prefersIdentityColumns());
115
-    }
116
-
117
-    public function testSupportsIdentityColumns()
118
-    {
119
-        $this->assertTrue($this->_platform->supportsIdentityColumns());
120
-    }
121
-
122
-    public function testDoesNotSupportSavePoints()
123
-    {
124
-        $this->assertTrue($this->_platform->supportsSavepoints());
125
-    }
126
-
127
-    public function getGenerateIndexSql()
128
-    {
129
-        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
130
-    }
131
-
132
-    public function getGenerateUniqueIndexSql()
133
-    {
134
-        return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL';
135
-    }
136
-
137
-    public function getGenerateForeignKeySql()
138
-    {
139
-        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)';
140
-    }
141
-
142
-    public function testModifyLimitQuery()
143
-    {
144
-        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
145
-        $this->assertEquals('SELECT TOP 10 * FROM user', $sql);
146
-    }
147
-
148
-    public function testModifyLimitQueryWithEmptyOffset()
149
-    {
150
-        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
151
-        $this->assertEquals('SELECT TOP 10 * FROM user', $sql);
152
-    }
153
-
154
-    public function testModifyLimitQueryWithOffset()
155
-    {
156
-        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5);
157
-        $this->assertEquals('SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS doctrine_rownum, * FROM user) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 6 AND 15', $sql);
158
-    }
159
-
160
-    public function testModifyLimitQueryWithAscOrderBy()
161
-    {
162
-        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
163
-        $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username ASC', $sql);
164
-    }
165
-
166
-    public function testModifyLimitQueryWithDescOrderBy()
167
-    {
168
-        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
169
-        $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql);
170
-    }
171
-
172
-    /**
173
-     * @group DDC-1360
174
-     */
175
-    public function testQuoteIdentifier()
176
-    {
177
-        $this->assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o'));
178
-        $this->assertEquals('[test]', $this->_platform->quoteIdentifier('test'));
179
-        $this->assertEquals('[test].[test]', $this->_platform->quoteIdentifier('test.test'));
180
-    }
181
-
182
-    /**
183
-     * @group DDC-1360
184
-     */
185
-    public function testQuoteSingleIdentifier()
186
-    {
187
-        $this->assertEquals('[fo][o]', $this->_platform->quoteSingleIdentifier('fo]o'));
188
-        $this->assertEquals('[test]', $this->_platform->quoteSingleIdentifier('test'));
189
-        $this->assertEquals('[test.test]', $this->_platform->quoteSingleIdentifier('test.test'));
190
-    }
191
-
192
-    /**
193
-     * @group DBAL-220
194
-     */
195
-    public function testCreateClusteredIndex()
196
-    {
197
-        $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'));
198
-        $idx->addFlag('clustered');
199
-        $this->assertEquals('CREATE CLUSTERED INDEX idx ON tbl (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl'));
200
-    }
201
-
202
-    /**
203
-     * @group DBAL-220
204
-     */
205
-    public function testCreateNonClusteredPrimaryKeyInTable()
206
-    {
207
-        $table = new \Doctrine\DBAL\Schema\Table("tbl");
208
-        $table->addColumn("id", "integer");
209
-        $table->setPrimaryKey(Array("id"));
210
-        $table->getIndex('primary')->addFlag('nonclustered');
211
-
212
-        $this->assertEquals(array('CREATE TABLE tbl (id INT NOT NULL, PRIMARY KEY NONCLUSTERED (id))'), $this->_platform->getCreateTableSQL($table));
213
-    }
214
-
215
-    /**
216
-     * @group DBAL-220
217
-     */
218
-    public function testCreateNonClusteredPrimaryKey()
219
-    {
220
-        $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true);
221
-        $idx->addFlag('nonclustered');
222
-        $this->assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->_platform->getCreatePrimaryKeySQL($idx, 'tbl'));
223
-    }
224
-
225
-    public function testAlterAddPrimaryKey()
226
-    {
227
-        $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true);
228
-        $this->assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl'));
229
-    }
230
-
231
-    protected function getQuotedColumnInPrimaryKeySQL()
232
-    {
233
-        return array(
234
-            'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL, PRIMARY KEY ([key]))',
235
-        );
236
-    }
237
-
238
-    protected function getQuotedColumnInIndexSQL()
239
-    {
240
-        return array(
241
-            'CREATE TABLE [quoted] ([key] NVARCHAR(255) NOT NULL)',
242
-            'CREATE INDEX IDX_22660D028A90ABA9 ON [quoted] ([key])',
243
-        );
244
-    }
245
-}

+ 0 - 252
vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php View File

@@ -1,252 +0,0 @@
1
-<?php
2
-
3
-namespace Doctrine\Tests\DBAL;
4
-
5
-use Doctrine\DBAL\Connection;
6
-use Doctrine\DBAL\SQLParserUtils;
7
-
8
-require_once __DIR__ . '/../TestInit.php';
9
-
10
-/**
11
- * @group DBAL-78
12
- * @group DDC-1372
13
- */
14
-class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
15
-{
16
-    static public function dataGetPlaceholderPositions()
17
-    {
18
-        return array(
19
-            // none
20
-            array('SELECT * FROM Foo', true, array()),
21
-            array('SELECT * FROM Foo', false, array()),
22
-
23
-            // Positionals
24
-            array('SELECT ?', true, array(7)),
25
-            array('SELECT * FROM Foo WHERE bar IN (?, ?, ?)', true, array(32, 35, 38)),
26
-            array('SELECT ? FROM ?', true, array(7, 14)),
27
-            array('SELECT "?" FROM foo', true, array()),
28
-            array("SELECT '?' FROM foo", true, array()),
29
-            array('SELECT "?" FROM foo WHERE bar = ?', true, array(32)),
30
-            array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)),
31
-
32
-            // named
33
-            array('SELECT :foo FROM :bar', false, array(7 => 'foo', 17 => 'bar')),
34
-            array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(32 => 'name1', 40 => 'name2')),
35
-            array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(37 => 'name1', 45 => 'name2')),
36
-            array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(37 => 'name1', 45 => 'name2')),
37
-            array('SELECT :foo_id', false, array(7 => 'foo_id')), // Ticket DBAL-231
38
-            array('SELECT @rank := 1', false, array()), // Ticket DBAL-398
39
-            array('SELECT @rank := 1 AS rank, :foo AS foo FROM :bar', false, array(27 => 'foo', 44 => 'bar')), // Ticket DBAL-398
40
-        );
41
-    }
42
-
43
-    /**
44
-     * @dataProvider dataGetPlaceholderPositions
45
-     * @param type $query
46
-     * @param type $isPositional
47
-     * @param type $expectedParamPos
48
-     */
49
-    public function testGetPlaceholderPositions($query, $isPositional, $expectedParamPos)
50
-    {
51
-        $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional);
52
-        $this->assertEquals($expectedParamPos, $actualParamPos);
53
-    }
54
-
55
-    static public function dataExpandListParameters()
56
-    {
57
-        return array(
58
-            // Positional: Very simple with one needle
59
-            array(
60
-                "SELECT * FROM Foo WHERE foo IN (?)",
61
-                array(array(1, 2, 3)),
62
-                array(Connection::PARAM_INT_ARRAY),
63
-                'SELECT * FROM Foo WHERE foo IN (?, ?, ?)',
64
-                array(1, 2, 3),
65
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
66
-            ),
67
-            // Positional: One non-list before d one after list-needle
68
-            array(
69
-                "SELECT * FROM Foo WHERE foo = ? AND bar IN (?)",
70
-                array("string", array(1, 2, 3)),
71
-                array(\PDO::PARAM_STR, Connection::PARAM_INT_ARRAY),
72
-                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)',
73
-                array("string", 1, 2, 3),
74
-                array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
75
-            ),
76
-            // Positional: One non-list after list-needle
77
-            array(
78
-                "SELECT * FROM Foo WHERE bar IN (?) AND baz = ?",
79
-                array(array(1, 2, 3), "foo"),
80
-                array(Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR),
81
-                'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?',
82
-                array(1, 2, 3, "foo"),
83
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR)
84
-            ),
85
-            // Positional: One non-list before and one after list-needle
86
-            array(
87
-                "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?",
88
-                array(1, array(1, 2, 3), 4),
89
-                array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY, \PDO::PARAM_INT),
90
-                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
91
-                array(1, 1, 2, 3, 4),
92
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
93
-            ),
94
-            // Positional: Two lists
95
-            array(
96
-                "SELECT * FROM Foo WHERE foo IN (?, ?)",
97
-                array(array(1, 2, 3), array(4, 5)),
98
-                array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY),
99
-                'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
100
-                array(1, 2, 3, 4, 5),
101
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
102
-            ),
103
-            //  Positional : Empty "integer" array DDC-1978
104
-            array(
105
-                "SELECT * FROM Foo WHERE foo IN (?)",
106
-                array('foo'=>array()),
107
-                array('foo'=>Connection::PARAM_INT_ARRAY),
108
-                'SELECT * FROM Foo WHERE foo IN (?)',
109
-                array(),
110
-                array()
111
-            ),
112
-            //  Positional : Empty "str" array DDC-1978
113
-            array(
114
-                "SELECT * FROM Foo WHERE foo IN (?)",
115
-                array('foo'=>array()),
116
-                array('foo'=>Connection::PARAM_STR_ARRAY),
117
-                'SELECT * FROM Foo WHERE foo IN (?)',
118
-                array(),
119
-                array()
120
-            ),
121
-            //  Named parameters : Very simple with param int
122
-            array(
123
-                "SELECT * FROM Foo WHERE foo = :foo",
124
-                array('foo'=>1),
125
-                array('foo'=>\PDO::PARAM_INT),
126
-                'SELECT * FROM Foo WHERE foo = ?',
127
-                array(1),
128
-                array(\PDO::PARAM_INT)
129
-            ),
130
-
131
-             //  Named parameters : Very simple with param int and string
132
-            array(
133
-                "SELECT * FROM Foo WHERE foo = :foo AND bar = :bar",
134
-                array('bar'=>'Some String','foo'=>1),
135
-                array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_STR),
136
-                'SELECT * FROM Foo WHERE foo = ? AND bar = ?',
137
-                array(1,'Some String'),
138
-                array(\PDO::PARAM_INT, \PDO::PARAM_STR)
139
-            ),
140
-
141
-            //  Named parameters : Very simple with one needle
142
-            array(
143
-                "SELECT * FROM Foo WHERE foo IN (:foo)",
144
-                array('foo'=>array(1, 2, 3)),
145
-                array('foo'=>Connection::PARAM_INT_ARRAY),
146
-                'SELECT * FROM Foo WHERE foo IN (?, ?, ?)',
147
-                array(1, 2, 3),
148
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
149
-            ),
150
-            // Named parameters: One non-list before d one after list-needle
151
-            array(
152
-                "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)",
153
-                array('foo'=>"string", 'bar'=>array(1, 2, 3)),
154
-                array('foo'=>\PDO::PARAM_STR, 'bar'=>Connection::PARAM_INT_ARRAY),
155
-                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)',
156
-                array("string", 1, 2, 3),
157
-                array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
158
-            ),
159
-            // Named parameters: One non-list after list-needle
160
-            array(
161
-                "SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz",
162
-                array('bar'=>array(1, 2, 3), 'baz'=>"foo"),
163
-                array('bar'=>Connection::PARAM_INT_ARRAY, 'baz'=>\PDO::PARAM_STR),
164
-                'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?',
165
-                array(1, 2, 3, "foo"),
166
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR)
167
-            ),
168
-            // Named parameters: One non-list before and one after list-needle
169
-            array(
170
-                "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz",
171
-                array('bar'=>array(1, 2, 3),'foo'=>1, 'baz'=>4),
172
-                array('bar'=>Connection::PARAM_INT_ARRAY, 'foo'=>\PDO::PARAM_INT, 'baz'=>\PDO::PARAM_INT),
173
-                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
174
-                array(1, 1, 2, 3, 4),
175
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
176
-            ),
177
-            // Named parameters: Two lists
178
-            array(
179
-                "SELECT * FROM Foo WHERE foo IN (:a, :b)",
180
-                array('b'=>array(4, 5),'a'=>array(1, 2, 3)),
181
-                array('a'=>Connection::PARAM_INT_ARRAY, 'b'=>Connection::PARAM_INT_ARRAY),
182
-                'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
183
-                array(1, 2, 3, 4, 5),
184
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
185
-            ),
186
-            //  Named parameters : With the same name arg type string
187
-            array(
188
-                "SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg",
189
-                array('arg'=>"Some String"),
190
-                array('arg'=>\PDO::PARAM_STR),
191
-                'SELECT * FROM Foo WHERE foo <> ? AND bar = ?',
192
-                array("Some String","Some String"),
193
-                array(\PDO::PARAM_STR,\PDO::PARAM_STR,)
194
-            ),
195
-             //  Named parameters : With the same name arg
196
-            array(
197
-                "SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)",
198
-                array('arg'=>array(1, 2, 3)),
199
-                array('arg'=>Connection::PARAM_INT_ARRAY),
200
-                'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)',
201
-                array(1, 2, 3, 1, 2, 3),
202
-                array(\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT,\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT)
203
-            ),
204
-
205
-             //  Named parameters : Same name, other name in between DBAL-299
206
-            array(
207
-                "SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)",
208
-                array('foo'=>2,'bar'=>3),
209
-                array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_INT),
210
-                'SELECT * FROM Foo WHERE (? = 2) AND (? = 3) AND (? = 2)',
211
-                array(2, 3, 2),
212
-                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
213
-            ),
214
-             //  Named parameters : Empty "integer" array DDC-1978
215
-            array(
216
-                "SELECT * FROM Foo WHERE foo IN (:foo)",
217
-                array('foo'=>array()),
218
-                array('foo'=>Connection::PARAM_INT_ARRAY),
219
-                'SELECT * FROM Foo WHERE foo IN (?)',
220
-                array(),
221
-                array()
222
-            ),
223
-             //  Named parameters : Two empty "str" array DDC-1978
224
-            array(
225
-                "SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)",
226
-                array('foo'=>array(), 'bar'=>array()),
227
-                array('foo'=>Connection::PARAM_STR_ARRAY, 'bar'=>Connection::PARAM_STR_ARRAY),
228
-                'SELECT * FROM Foo WHERE foo IN (?) OR bar IN (?)',
229
-                array(),
230
-                array()
231
-            ),
232
-        );
233
-    }
234
-
235
-    /**
236
-     * @dataProvider dataExpandListParameters
237
-     * @param type $q
238
-     * @param type $p
239
-     * @param type $t
240
-     * @param type $expectedQuery
241
-     * @param type $expectedParams
242
-     * @param type $expectedTypes
243
-     */
244
-    public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes)
245
-    {
246
-        list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t);
247
-
248
-        $this->assertEquals($expectedQuery, $query, "Query was not rewritten correctly.");
249
-        $this->assertEquals($expectedParams, $params, "Params dont match");
250
-        $this->assertEquals($expectedTypes, $types, "Types dont match");
251
-    }
252
-}

+ 0 - 8
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.travis.yml View File

@@ -1,8 +0,0 @@
1
-language: php
2
-
3
-php:
4
-  - 5.3
5
-  - 5.4
6
-
7
-before_script: composer install --dev
8
-

+ 0 - 32
vendor/doctrine/orm/composer.json View File

@@ -1,32 +0,0 @@
1
-{
2
-    "name": "doctrine/orm",
3
-    "type": "library","version":"2.3.2",
4
-    "description": "Object-Relational-Mapper for PHP",
5
-    "keywords": ["orm", "database"],
6
-    "homepage": "http://www.doctrine-project.org",
7
-    "license": "MIT",
8
-    "authors": [
9
-        {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
10
-        {"name": "Roman Borschel", "email": "roman@code-factory.org"},
11
-        {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
12
-        {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
13
-    ],
14
-    "require": {
15
-        "php": ">=5.3.2",
16
-        "ext-pdo": "*",
17
-        "doctrine/dbal": "2.3.*",
18
-        "symfony/console": "2.*"
19
-    },
20
-    "suggest": {
21
-        "symfony/yaml": "If you want to use YAML Metadata Mapping Driver"
22
-    },
23
-    "autoload": {
24
-        "psr-0": { "Doctrine\\ORM": "lib/" }
25
-    },
26
-    "bin": ["bin/doctrine", "bin/doctrine.php"],
27
-    "extra": {
28
-        "branch-alias": {
29
-            "dev-master": "2.3.x-dev"
30
-        }
31
-    }
32
-}

+ 0 - 59
vendor/doctrine/orm/lib/Doctrine/ORM/Id/IdentityGenerator.php View File

@@ -1,59 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-namespace Doctrine\ORM\Id;
21
-
22
-use Doctrine\ORM\EntityManager;
23
-
24
-/**
25
- * Id generator that obtains IDs from special "identity" columns. These are columns
26
- * that automatically get a database-generated, auto-incremented identifier on INSERT.
27
- * This generator obtains the last insert id after such an insert.
28
- */
29
-class IdentityGenerator extends AbstractIdGenerator
30
-{
31
-    /** @var string The name of the sequence to pass to lastInsertId(), if any. */
32
-    private $_seqName;
33
-
34
-    /**
35
-     * @param string $seqName The name of the sequence to pass to lastInsertId()
36
-     *                        to obtain the last generated identifier within the current
37
-     *                        database session/connection, if any.
38
-     */
39
-    public function __construct($seqName = null)
40
-    {
41
-        $this->_seqName = $seqName;
42
-    }
43
-
44
-    /**
45
-     * {@inheritdoc}
46
-     */
47
-    public function generate(EntityManager $em, $entity)
48
-    {
49
-        return (int)$em->getConnection()->lastInsertId($this->_seqName);
50
-    }
51
-
52
-    /**
53
-     * {@inheritdoc}
54
-     */
55
-    public function isPostInsertGenerator()
56
-    {
57
-        return true;
58
-    }
59
-}

+ 0 - 537
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php View File

@@ -1,537 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-namespace Doctrine\ORM\Mapping;
21
-
22
-use ReflectionException,
23
-    Doctrine\ORM\ORMException,
24
-    Doctrine\ORM\EntityManager,
25
-    Doctrine\DBAL\Platforms,
26
-    Doctrine\ORM\Events,
27
-    Doctrine\Common\Persistence\Mapping\ReflectionService,
28
-    Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface,
29
-    Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory,
30
-    Doctrine\ORM\Id\IdentityGenerator,
31
-    Doctrine\ORM\Event\LoadClassMetadataEventArgs;
32
-
33
-/**
34
- * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
35
- * metadata mapping information of a class which describes how a class should be mapped
36
- * to a relational database.
37
- *
38
- * @since   2.0
39
- * @author  Benjamin Eberlei <kontakt@beberlei.de>
40
- * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
41
- * @author  Jonathan Wage <jonwage@gmail.com>
42
- * @author  Roman Borschel <roman@code-factory.org>
43
- */
44
-class ClassMetadataFactory extends AbstractClassMetadataFactory
45
-{
46
-    /**
47
-     * @var EntityManager
48
-     */
49
-    private $em;
50
-
51
-    /**
52
-     * @var \Doctrine\DBAL\Platforms\AbstractPlatform
53
-     */
54
-    private $targetPlatform;
55
-
56
-    /**
57
-     * @var \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
58
-     */
59
-    private $driver;
60
-
61
-    /**
62
-     * @var \Doctrine\Common\EventManager
63
-     */
64
-    private $evm;
65
-
66
-    /**
67
-     * @param EntityManager $em
68
-     */
69
-    public function setEntityManager(EntityManager $em)
70
-    {
71
-        $this->em = $em;
72
-    }
73
-
74
-    /**
75
-     * {@inheritDoc}.
76
-     */
77
-    protected function initialize()
78
-    {
79
-        $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl();
80
-        $this->targetPlatform = $this->em->getConnection()->getDatabasePlatform();
81
-        $this->evm = $this->em->getEventManager();
82
-        $this->initialized = true;
83
-    }
84
-
85
-    /**
86
-     * {@inheritDoc}
87
-     */
88
-    protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
89
-    {
90
-        /* @var $class ClassMetadata */
91
-        /* @var $parent ClassMetadata */
92
-        if ($parent) {
93
-            $class->setInheritanceType($parent->inheritanceType);
94
-            $class->setDiscriminatorColumn($parent->discriminatorColumn);
95
-            $class->setIdGeneratorType($parent->generatorType);
96
-            $this->addInheritedFields($class, $parent);
97
-            $this->addInheritedRelations($class, $parent);
98
-            $class->setIdentifier($parent->identifier);
99
-            $class->setVersioned($parent->isVersioned);
100
-            $class->setVersionField($parent->versionField);
101
-            $class->setDiscriminatorMap($parent->discriminatorMap);
102
-            $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
103
-            $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
104
-
105
-            if ($parent->isMappedSuperclass) {
106
-                $class->setCustomRepositoryClass($parent->customRepositoryClassName);
107
-            }
108
-        }
109
-
110
-        // Invoke driver
111
-        try {
112
-            $this->driver->loadMetadataForClass($class->getName(), $class);
113
-        } catch (ReflectionException $e) {
114
-            throw MappingException::reflectionFailure($class->getName(), $e);
115
-        }
116
-
117
-        // If this class has a parent the id generator strategy is inherited.
118
-        // However this is only true if the hierarchy of parents contains the root entity,
119
-        // if it consists of mapped superclasses these don't necessarily include the id field.
120
-        if ($parent && $rootEntityFound) {
121
-            if ($parent->isIdGeneratorSequence()) {
122
-                $class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition);
123
-            } else if ($parent->isIdGeneratorTable()) {
124
-                $class->tableGeneratorDefinition = $parent->tableGeneratorDefinition;
125
-            }
126
-
127
-            if ($parent->generatorType) {
128
-                $class->setIdGeneratorType($parent->generatorType);
129
-            }
130
-
131
-            if ($parent->idGenerator) {
132
-                $class->setIdGenerator($parent->idGenerator);
133
-            }
134
-        } else {
135
-            $this->completeIdGeneratorMapping($class);
136
-        }
137
-
138
-        if ($parent && $parent->isInheritanceTypeSingleTable()) {
139
-            $class->setPrimaryTable($parent->table);
140
-        }
141
-
142
-        if ($parent && $parent->containsForeignIdentifier) {
143
-            $class->containsForeignIdentifier = true;
144
-        }
145
-
146
-        if ($parent && !empty($parent->namedQueries)) {
147
-            $this->addInheritedNamedQueries($class, $parent);
148
-        }
149
-
150
-        if ($parent && !empty($parent->namedNativeQueries)) {
151
-            $this->addInheritedNamedNativeQueries($class, $parent);
152
-        }
153
-
154
-        if ($parent && !empty($parent->sqlResultSetMappings)) {
155
-            $this->addInheritedSqlResultSetMappings($class, $parent);
156
-        }
157
-
158
-        $class->setParentClasses($nonSuperclassParents);
159
-
160
-        if ( $class->isRootEntity() && ! $class->isInheritanceTypeNone() && ! $class->discriminatorMap) {
161
-            $this->addDefaultDiscriminatorMap($class);
162
-        }
163
-
164
-        if ($this->evm->hasListeners(Events::loadClassMetadata)) {
165
-            $eventArgs = new LoadClassMetadataEventArgs($class, $this->em);
166
-            $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
167
-        }
168
-
169
-        $this->wakeupReflection($class, $this->getReflectionService());
170
-        $this->validateRuntimeMetadata($class, $parent);
171
-    }
172
-
173
-    /**
174
-     * Validate runtime metadata is correctly defined.
175
-     *
176
-     * @param ClassMetadata $class
177
-     * @param $parent
178
-     * @throws MappingException
179
-     */
180
-    protected function validateRuntimeMetadata($class, $parent)
181
-    {
182
-        if ( ! $class->reflClass ) {
183
-            // only validate if there is a reflection class instance
184
-            return;
185
-        }
186
-
187
-        $class->validateIdentifier();
188
-        $class->validateAssocations();
189
-        $class->validateLifecycleCallbacks($this->getReflectionService());
190
-
191
-        // verify inheritance
192
-        if ( ! $class->isMappedSuperclass && !$class->isInheritanceTypeNone()) {
193
-            if ( ! $parent) {
194
-                if (count($class->discriminatorMap) == 0) {
195
-                    throw MappingException::missingDiscriminatorMap($class->name);
196
-                }
197
-                if ( ! $class->discriminatorColumn) {
198
-                    throw MappingException::missingDiscriminatorColumn($class->name);
199
-                }
200
-            } else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
201
-                // enforce discriminator map for all entities of an inheritance hierarchy, otherwise problems will occur.
202
-                throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
203
-            }
204
-        } else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
205
-            // second condition is necessary for mapped superclasses in the middle of an inheritance hierarchy
206
-            throw MappingException::noInheritanceOnMappedSuperClass($class->name);
207
-        }
208
-    }
209
-
210
-    /**
211
-     * {@inheritDoc}
212
-     */
213
-    protected function newClassMetadataInstance($className)
214
-    {
215
-        return new ClassMetadata($className, $this->em->getConfiguration()->getNamingStrategy());
216
-    }
217
-
218
-    /**
219
-     * Adds a default discriminator map if no one is given
220
-     *
221
-     * If an entity is of any inheritance type and does not contain a
222
-     * discriminator map, then the map is generated automatically. This process
223
-     * is expensive computation wise.
224
-     *
225
-     * The automatically generated discriminator map contains the lowercase short name of
226
-     * each class as key.
227
-     *
228
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $class
229
-     * @throws MappingException
230
-     */
231
-    private function addDefaultDiscriminatorMap(ClassMetadata $class)
232
-    {
233
-        $allClasses = $this->driver->getAllClassNames();
234
-        $fqcn = $class->getName();
235
-        $map = array($this->getShortName($class->name) => $fqcn);
236
-
237
-        $duplicates = array();
238
-        foreach ($allClasses as $subClassCandidate) {
239
-            if (is_subclass_of($subClassCandidate, $fqcn)) {
240
-                $shortName = $this->getShortName($subClassCandidate);
241
-
242
-                if (isset($map[$shortName])) {
243
-                    $duplicates[] = $shortName;
244
-                }
245
-
246
-                $map[$shortName] = $subClassCandidate;
247
-            }
248
-        }
249
-
250
-        if ($duplicates) {
251
-            throw MappingException::duplicateDiscriminatorEntry($class->name, $duplicates, $map);
252
-        }
253
-
254
-        $class->setDiscriminatorMap($map);
255
-    }
256
-
257
-    /**
258
-     * Get the lower-case short name of a class.
259
-     *
260
-     * @param string $className
261
-     * @return string
262
-     */
263
-    private function getShortName($className)
264
-    {
265
-        if (strpos($className, "\\") === false) {
266
-            return strtolower($className);
267
-        }
268
-
269
-        $parts = explode("\\", $className);
270
-        return strtolower(end($parts));
271
-    }
272
-
273
-    /**
274
-     * Adds inherited fields to the subclass mapping.
275
-     *
276
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
277
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
278
-     */
279
-    private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
280
-    {
281
-        foreach ($parentClass->fieldMappings as $mapping) {
282
-            if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
283
-                $mapping['inherited'] = $parentClass->name;
284
-            }
285
-            if ( ! isset($mapping['declared'])) {
286
-                $mapping['declared'] = $parentClass->name;
287
-            }
288
-            $subClass->addInheritedFieldMapping($mapping);
289
-        }
290
-        foreach ($parentClass->reflFields as $name => $field) {
291
-            $subClass->reflFields[$name] = $field;
292
-        }
293
-    }
294
-
295
-    /**
296
-     * Adds inherited association mappings to the subclass mapping.
297
-     *
298
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
299
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
300
-     * @throws MappingException
301
-     */
302
-    private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
303
-    {
304
-        foreach ($parentClass->associationMappings as $field => $mapping) {
305
-            if ($parentClass->isMappedSuperclass) {
306
-                if ($mapping['type'] & ClassMetadata::TO_MANY && !$mapping['isOwningSide']) {
307
-                    throw MappingException::illegalToManyAssocationOnMappedSuperclass($parentClass->name, $field);
308
-                }
309
-                $mapping['sourceEntity'] = $subClass->name;
310
-            }
311
-
312
-            //$subclassMapping = $mapping;
313
-            if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
314
-                $mapping['inherited'] = $parentClass->name;
315
-            }
316
-            if ( ! isset($mapping['declared'])) {
317
-                $mapping['declared'] = $parentClass->name;
318
-            }
319
-            $subClass->addInheritedAssociationMapping($mapping);
320
-        }
321
-    }
322
-
323
-    /**
324
-     * Adds inherited named queries to the subclass mapping.
325
-     *
326
-     * @since 2.2
327
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
328
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
329
-     */
330
-    private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
331
-    {
332
-        foreach ($parentClass->namedQueries as $name => $query) {
333
-            if ( ! isset ($subClass->namedQueries[$name])) {
334
-                $subClass->addNamedQuery(array(
335
-                    'name'  => $query['name'],
336
-                    'query' => $query['query']
337
-                ));
338
-            }
339
-        }
340
-    }
341
-
342
-    /**
343
-     * Adds inherited named native queries to the subclass mapping.
344
-     *
345
-     * @since 2.3
346
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
347
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
348
-     */
349
-    private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass)
350
-    {
351
-        foreach ($parentClass->namedNativeQueries as $name => $query) {
352
-            if ( ! isset ($subClass->namedNativeQueries[$name])) {
353
-                $subClass->addNamedNativeQuery(array(
354
-                    'name'              => $query['name'],
355
-                    'query'             => $query['query'],
356
-                    'isSelfClass'       => $query['isSelfClass'],
357
-                    'resultSetMapping'  => $query['resultSetMapping'],
358
-                    'resultClass'       => $query['isSelfClass'] ? $subClass->name : $query['resultClass'],
359
-                ));
360
-            }
361
-        }
362
-    }
363
-
364
-    /**
365
-     * Adds inherited sql result set mappings to the subclass mapping.
366
-     *
367
-     * @since 2.3
368
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $subClass
369
-     * @param \Doctrine\ORM\Mapping\ClassMetadata $parentClass
370
-     */
371
-    private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass)
372
-    {
373
-        foreach ($parentClass->sqlResultSetMappings as $name => $mapping) {
374
-            if ( ! isset ($subClass->sqlResultSetMappings[$name])) {
375
-                $entities = array();
376
-                foreach ($mapping['entities'] as $entity) {
377
-                    $entities[] = array(
378
-                        'fields'                => $entity['fields'],
379
-                        'isSelfClass'           => $entity['isSelfClass'],
380
-                        'discriminatorColumn'   => $entity['discriminatorColumn'],
381
-                        'entityClass'           => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'],
382
-                    );
383
-                }
384
-
385
-                $subClass->addSqlResultSetMapping(array(
386
-                    'name'          => $mapping['name'],
387
-                    'columns'       => $mapping['columns'],
388
-                    'entities'      => $entities,
389
-                ));
390
-            }
391
-        }
392
-    }
393
-
394
-    /**
395
-     * Completes the ID generator mapping. If "auto" is specified we choose the generator
396
-     * most appropriate for the targeted database platform.
397
-     *
398
-     * @param ClassMetadataInfo $class
399
-     * @throws ORMException
400
-     */
401
-    private function completeIdGeneratorMapping(ClassMetadataInfo $class)
402
-    {
403
-        $idGenType = $class->generatorType;
404
-        if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
405
-            if ($this->targetPlatform->prefersSequences()) {
406
-                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
407
-            } else if ($this->targetPlatform->prefersIdentityColumns()) {
408
-                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY);
409
-            } else {
410
-                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_TABLE);
411
-            }
412
-        }
413
-
414
-        // Create & assign an appropriate ID generator instance
415
-        switch ($class->generatorType) {
416
-            case ClassMetadata::GENERATOR_TYPE_IDENTITY:
417
-                // For PostgreSQL IDENTITY (SERIAL) we need a sequence name. It defaults to
418
-                // <table>_<column>_seq in PostgreSQL for SERIAL columns.
419
-                // Not pretty but necessary and the simplest solution that currently works.
420
-                $sequenceName = null;
421
-
422
-                if ($this->targetPlatform instanceof Platforms\PostgreSQLPlatform) {
423
-                    $fieldName      = $class->getSingleIdentifierFieldName();
424
-                    $columnName     = $class->getSingleIdentifierColumnName();
425
-                    $quoted         = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
426
-                    $sequenceName   = $class->getTableName() . '_' . $columnName . '_seq';
427
-                    $definition     = array(
428
-                        'sequenceName' => $this->targetPlatform->fixSchemaElementName($sequenceName)
429
-                    );
430
-
431
-                    if ($quoted) {
432
-                        $definition['quoted'] = true;
433
-                    }
434
-
435
-                    $sequenceName = $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform);
436
-                }
437
-
438
-                $class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($sequenceName));
439
-                break;
440
-
441
-            case ClassMetadata::GENERATOR_TYPE_SEQUENCE:
442
-                // If there is no sequence definition yet, create a default definition
443
-                $definition = $class->sequenceGeneratorDefinition;
444
-
445
-                if ( ! $definition) {
446
-                    $fieldName      = $class->getSingleIdentifierFieldName();
447
-                    $columnName     = $class->getSingleIdentifierColumnName();
448
-                    $quoted         = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
449
-                    $sequenceName   = $class->getTableName() . '_' . $columnName . '_seq';
450
-                    $definition     = array(
451
-                        'sequenceName'      => $this->targetPlatform->fixSchemaElementName($sequenceName),
452
-                        'allocationSize'    => 1,
453
-                        'initialValue'      => 1,
454
-                    );
455
-
456
-                    if ($quoted) {
457
-                        $definition['quoted'] = true;
458
-                    }
459
-
460
-                    $class->setSequenceGeneratorDefinition($definition);
461
-                }
462
-
463
-                $sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator(
464
-                    $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->targetPlatform),
465
-                    $definition['allocationSize']
466
-                );
467
-                $class->setIdGenerator($sequenceGenerator);
468
-                break;
469
-
470
-            case ClassMetadata::GENERATOR_TYPE_NONE:
471
-                $class->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
472
-                break;
473
-
474
-            case ClassMetadata::GENERATOR_TYPE_UUID:
475
-                $class->setIdGenerator(new \Doctrine\ORM\Id\UuidGenerator());
476
-                break;
477
-
478
-            case ClassMetadata::GENERATOR_TYPE_TABLE:
479
-                throw new ORMException("TableGenerator not yet implemented.");
480
-                break;
481
-
482
-            case ClassMetadata::GENERATOR_TYPE_CUSTOM:
483
-                $definition = $class->customGeneratorDefinition;
484
-                if ( ! class_exists($definition['class'])) {
485
-                    throw new ORMException("Can't instantiate custom generator : " .
486
-                        $definition['class']);
487
-                }
488
-                $class->setIdGenerator(new $definition['class']);
489
-                break;
490
-
491
-            default:
492
-                throw new ORMException("Unknown generator type: " . $class->generatorType);
493
-        }
494
-    }
495
-
496
-    /**
497
-     * {@inheritDoc}
498
-     */
499
-    protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService)
500
-    {
501
-        /* @var $class ClassMetadata */
502
-        $class->wakeupReflection($reflService);
503
-    }
504
-
505
-    /**
506
-     * {@inheritDoc}
507
-     */
508
-    protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService)
509
-    {
510
-        /* @var $class ClassMetadata */
511
-        $class->initializeReflection($reflService);
512
-    }
513
-
514
-    /**
515
-     * {@inheritDoc}
516
-     */
517
-    protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
518
-    {
519
-        return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
520
-    }
521
-
522
-    /**
523
-     * {@inheritDoc}
524
-     */
525
-    protected function getDriver()
526
-    {
527
-        return $this->driver;
528
-    }
529
-
530
-    /**
531
-     * {@inheritDoc}
532
-     */
533
-    protected function isEntity(ClassMetadataInterface $class)
534
-    {
535
-        return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false;
536
-    }
537
-}

File diff suppressed because it is too large
+ 0 - 3050
vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php


+ 0 - 55
vendor/doctrine/orm/lib/Doctrine/ORM/Version.php View File

@@ -1,55 +0,0 @@
1
-<?php
2
-/*
3
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
- *
15
- * This software consists of voluntary contributions made by many individuals
16
- * and is licensed under the MIT license. For more information, see
17
- * <http://www.doctrine-project.org>.
18
- */
19
-
20
-namespace Doctrine\ORM;
21
-
22
-/**
23
- * Class to store and retrieve the version of Doctrine
24
- *
25
- * 
26
- * @link    www.doctrine-project.org
27
- * @since   2.0
28
- * @version $Revision$
29
- * @author  Benjamin Eberlei <kontakt@beberlei.de>
30
- * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
31
- * @author  Jonathan Wage <jonwage@gmail.com>
32
- * @author  Roman Borschel <roman@code-factory.org>
33
- */
34
-class Version
35
-{
36
-    /**
37
-     * Current Doctrine Version
38
-     */
39
-    const VERSION = '2.3.2';
40
-
41
-    /**
42
-     * Compares a Doctrine version with the current one.
43
-     *
44
-     * @param string $version Doctrine version to compare.
45
-     * @return int Returns -1 if older, 0 if it is the same, 1 if version
46
-     *             passed as argument is newer.
47
-     */
48
-    public static function compare($version)
49
-    {
50
-        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
51
-        $version        = str_replace(' ', '', $version);
52
-
53
-        return version_compare($version, $currentVersion);
54
-    }
55
-}

+ 0 - 464
vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php View File

@@ -1,464 +0,0 @@
1
-<?php
2
-
3
-namespace Doctrine\Tests\ORM\Functional\Ticket;
4
-
5
-use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails;
6
-use Doctrine\Tests\Models\DDC117\DDC117Article;
7
-use Doctrine\Tests\Models\DDC117\DDC117Reference;
8
-use Doctrine\Tests\Models\DDC117\DDC117Translation;
9
-use Doctrine\Tests\Models\DDC117\DDC117ApproveChanges;
10
-use Doctrine\Tests\Models\DDC117\DDC117Editor;
11
-
12
-require_once __DIR__ . '/../../../TestInit.php';
13
-
14
-class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
15
-{
16
-    private $article1;
17
-    private $article2;
18
-    private $reference;
19
-    private $translation;
20
-    private $articleDetails;
21
-
22
-    protected function setUp() {
23
-        $this->useModelSet('ddc117');
24
-        parent::setUp();
25
-
26
-        $this->article1 = new DDC117Article("Foo");
27
-        $this->article2 = new DDC117Article("Bar");
28
-
29
-        $this->_em->persist($this->article1);
30
-        $this->_em->persist($this->article2);
31
-        $this->_em->flush();
32
-
33
-        $this->reference = new DDC117Reference($this->article1, $this->article2, "Test-Description");
34
-        $this->_em->persist($this->reference);
35
-
36
-        $this->translation = new DDC117Translation($this->article1, "en", "Bar");
37
-        $this->_em->persist($this->translation);
38
-
39
-        $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text");
40
-        $this->_em->persist($this->articleDetails);
41
-        $this->_em->flush();
42
-
43
-        $this->_em->clear();
44
-    }
45
-
46
-    /**
47
-     * @group DDC-117
48
-     */
49
-    public function testAssociationOnlyCompositeKey()
50
-    {
51
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
52
-
53
-        $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
54
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef);
55
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target());
56
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source());
57
-        $this->assertSame($mapRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria));
58
-
59
-        $this->_em->clear();
60
-
61
-        $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE r.source = ?1";
62
-        $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult();
63
-
64
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef);
65
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target());
66
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source());
67
-        $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria));
68
-
69
-        $this->_em->clear();
70
-
71
-        $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1";
72
-        $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
73
-
74
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $dqlRef);
75
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->target());
76
-        $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->source());
77
-        $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria));
78
-
79
-        $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1";
80
-        $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
81
-
82
-        $this->_em->contains($dqlRef);
83
-    }
84
-
85
-    /**
86
-     * @group DDC-117
87
-     */
88
-    public function testUpdateAssocationEntity()
89
-    {
90
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
91
-
92
-        $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
93
-        $this->assertNotNull($mapRef);
94
-        $mapRef->setDescription("New Description!!");
95
-        $this->_em->flush();
96
-        $this->_em->clear();
97
-
98
-        $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
99
-
100
-        $this->assertEquals('New Description!!', $mapRef->getDescription());
101
-    }
102
-
103
-    /**
104
-     * @group DDC-117
105
-     */
106
-    public function testFetchDql()
107
-    {
108
-        $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1";
109
-        $refs = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getResult();
110
-
111
-        $this->assertTrue(count($refs) > 0, "Has to contain at least one Reference.");
112
-
113
-        foreach ($refs AS $ref) {
114
-            $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $ref, "Contains only Reference instances.");
115
-            $this->assertTrue($this->_em->contains($ref), "Contains Reference in the IdentityMap.");
116
-        }
117
-    }
118
-
119
-    /**
120
-     * @group DDC-117
121
-     */
122
-    public function testRemoveCompositeElement()
123
-    {
124
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
125
-
126
-        $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
127
-
128
-        $this->_em->remove($refRep);
129
-        $this->_em->flush();
130
-        $this->_em->clear();
131
-
132
-        $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria));
133
-    }
134
-
135
-    /**
136
-     * @group DDC-117
137
-     */
138
-    public function testDqlRemoveCompositeElement()
139
-    {
140
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
141
-
142
-        $dql = "DELETE "."Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = ?1 AND r.target = ?2";
143
-        $this->_em->createQuery($dql)
144
-                  ->setParameter(1, $this->article1->id())
145
-                  ->setParameter(2, $this->article2->id())
146
-                  ->execute();
147
-
148
-        $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria));
149
-    }
150
-
151
-    /**
152
-     * @group DDC-117
153
-     */
154
-    public function testInverseSideAccess()
155
-    {
156
-        $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id());
157
-
158
-        $this->assertEquals(1, count($this->article1->references()));
159
-
160
-        foreach ($this->article1->references() AS $this->reference) {
161
-            $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference);
162
-            $this->assertSame($this->article1, $this->reference->source());
163
-        }
164
-
165
-        $this->_em->clear();
166
-
167
-        $dql = 'SELECT a, r FROM '. 'Doctrine\Tests\Models\DDC117\DDC117Article a INNER JOIN a.references r WHERE a.id = ?1';
168
-        $articleDql = $this->_em->createQuery($dql)
169
-                                ->setParameter(1, $this->article1->id())
170
-                                ->getSingleResult();
171
-
172
-        $this->assertEquals(1, count($this->article1->references()));
173
-
174
-        foreach ($this->article1->references() AS $this->reference) {
175
-            $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference);
176
-            $this->assertSame($this->article1, $this->reference->source());
177
-        }
178
-    }
179
-
180
-    /**
181
-     * @group DDC-117
182
-     */
183
-    public function testMixedCompositeKey()
184
-    {
185
-        $idCriteria = array('article' => $this->article1->id(), 'language' => 'en');
186
-
187
-        $this->translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria);
188
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation);
189
-
190
-        $this->assertSame($this->translation, $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria));
191
-
192
-        $this->_em->clear();
193
-
194
-        $dql = 'SELECT t, a FROM ' . 'Doctrine\Tests\Models\DDC117\DDC117Translation t JOIN t.article a WHERE t.article = ?1 AND t.language = ?2';
195
-        $dqlTrans = $this->_em->createQuery($dql)
196
-                              ->setParameter(1, $this->article1->id())
197
-                              ->setParameter(2, 'en')
198
-                              ->getSingleResult();
199
-
200
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation);
201
-    }
202
-
203
-    /**
204
-     * @group DDC-117
205
-     */
206
-    public function testMixedCompositeKeyViolateUniqueness()
207
-    {
208
-        $this->article1 = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Article', $this->article1->id());
209
-        $this->article1->addTranslation('en', 'Bar');
210
-        $this->article1->addTranslation('en', 'Baz');
211
-
212
-        $exceptionThrown = false;
213
-        try {
214
-            // exception depending on the underyling Database Driver
215
-            $this->_em->flush();
216
-        } catch(\Exception $e) {
217
-            $exceptionThrown = true;
218
-        }
219
-
220
-        $this->assertTrue($exceptionThrown, "The underlying database driver throws an exception.");
221
-    }
222
-
223
-    /**
224
-     * @group DDC-117
225
-     */
226
-    public function testOneToOneForeignObjectId()
227
-    {
228
-        $this->article1 = new DDC117Article("Foo");
229
-        $this->_em->persist($this->article1);
230
-        $this->_em->flush();
231
-
232
-        $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text");
233
-        $this->_em->persist($this->articleDetails);
234
-        $this->_em->flush();
235
-
236
-        $this->articleDetails->update("not so very long text!");
237
-        $this->_em->flush();
238
-        $this->_em->clear();
239
-
240
-        /* @var $article DDC117Article */
241
-        $article = $this->_em->find(get_class($this->article1), $this->article1->id());
242
-        $this->assertEquals('not so very long text!', $article->getText());
243
-    }
244
-
245
-    /**
246
-     * @group DDC-117
247
-     */
248
-    public function testOneToOneCascadeRemove()
249
-    {
250
-        $article = $this->_em->find(get_class($this->article1), $this->article1->id());
251
-        $this->_em->remove($article);
252
-        $this->_em->flush();
253
-
254
-        $this->assertFalse($this->_em->contains($article->getDetails()));
255
-    }
256
-
257
-    /**
258
-     * @group DDC-117
259
-     */
260
-    public function testOneToOneCascadePersist()
261
-    {
262
-        if (!$this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) {
263
-            $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.');
264
-        }
265
-
266
-        $this->article1 = new DDC117Article("Foo");
267
-
268
-        $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text");
269
-
270
-        $this->_em->persist($this->article1);
271
-        $this->_em->flush();
272
-    }
273
-
274
-    /**
275
-     * @group DDC-117
276
-     */
277
-    public function testReferencesToForeignKeyEntities()
278
-    {
279
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
280
-        $reference = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
281
-
282
-        $idCriteria = array('article' => $this->article1->id(), 'language' => 'en');
283
-        $translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria);
284
-
285
-        $approveChanges = new DDC117ApproveChanges($reference->source()->getDetails(), $reference, $translation);
286
-        $this->_em->persist($approveChanges);
287
-        $this->_em->flush();
288
-        $this->_em->clear();
289
-
290
-        $approveChanges = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117ApproveChanges", $approveChanges->getId());
291
-
292
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $approveChanges->getArticleDetails());
293
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Reference', $approveChanges->getReference());
294
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $approveChanges->getTranslation());
295
-    }
296
-
297
-    /**
298
-     * @group DDC-117
299
-     */
300
-    public function testLoadOneToManyCollectionOfForeignKeyEntities()
301
-    {
302
-        /* @var $article DDC117Article */
303
-        $article = $this->_em->find(get_class($this->article1), $this->article1->id());
304
-
305
-        $translations = $article->getTranslations();
306
-        $this->assertFalse($translations->isInitialized());
307
-        $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Translation', $translations);
308
-        $this->assertTrue($translations->isInitialized());
309
-    }
310
-
311
-    /**
312
-     * @group DDC-117
313
-     */
314
-    public function testLoadManyToManyCollectionOfForeignKeyEntities()
315
-    {
316
-        $editor = $this->loadEditorFixture();
317
-
318
-        $this->assertFalse($editor->reviewingTranslations->isInitialized());
319
-        $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations);
320
-        $this->assertTrue($editor->reviewingTranslations->isInitialized());
321
-
322
-        $this->_em->clear();
323
-
324
-        $dql = "SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1";
325
-        $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult();
326
-        $this->assertTrue($editor->reviewingTranslations->isInitialized());
327
-        $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations);
328
-    }
329
-
330
-    /**
331
-     * @group DDC-117
332
-     */
333
-    public function testClearManyToManyCollectionOfForeignKeyEntities()
334
-    {
335
-        $editor = $this->loadEditorFixture();
336
-        $this->assertEquals(3, count($editor->reviewingTranslations));
337
-
338
-        $editor->reviewingTranslations->clear();
339
-        $this->_em->flush();
340
-        $this->_em->clear();
341
-
342
-        $editor = $this->_em->find(get_class($editor), $editor->id);
343
-        $this->assertEquals(0, count($editor->reviewingTranslations));
344
-    }
345
-
346
-    /**
347
-     * @group DDC-117
348
-     */
349
-    public function testLoadInverseManyToManyCollection()
350
-    {
351
-        $editor = $this->loadEditorFixture();
352
-
353
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $editor->reviewingTranslations[0]);
354
-
355
-        $reviewedBy = $editor->reviewingTranslations[0]->getReviewedByEditors();
356
-        $this->assertEquals(1, count($reviewedBy));
357
-        $this->assertSame($editor, $reviewedBy[0]);
358
-
359
-        $this->_em->clear();
360
-
361
-        $dql = "SELECT t, e FROM Doctrine\Tests\Models\DDC117\DDC117Translation t ".
362
-               "JOIN t.reviewedByEditors e WHERE t.article = ?1 AND t.language = ?2";
363
-        $trans = $this->_em->createQuery($dql)
364
-                           ->setParameter(1, $this->translation->getArticleId())
365
-                           ->setParameter(2, $this->translation->getLanguage())
366
-                           ->getSingleResult();
367
-
368
-        $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $trans);
369
-        $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Editor', $trans->reviewedByEditors);
370
-        $this->assertEquals(1, count($trans->reviewedByEditors));
371
-    }
372
-
373
-    /**
374
-     * @group DDC-117
375
-     */
376
-    public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier()
377
-    {
378
-        $editor = $this->loadEditorFixture();
379
-
380
-        $editor->addLastTranslation($editor->reviewingTranslations[0]);
381
-        $this->_em->flush();
382
-        $this->_em->clear();
383
-
384
-        $editor = $this->_em->find(get_class($editor), $editor->id);
385
-        $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy();
386
-        $lastTranslatedBy->count();
387
-
388
-        $this->assertEquals(1, count($lastTranslatedBy));
389
-    }
390
-
391
-    /**
392
-     * @return DDC117Editor
393
-     */
394
-    private function loadEditorFixture()
395
-    {
396
-        $editor = new DDC117Editor("beberlei");
397
-
398
-        /* @var $article1 DDC117Article */
399
-        $article1 = $this->_em->find(get_class($this->article1), $this->article1->id());
400
-        foreach ($article1->getTranslations() AS $translation) {
401
-            $editor->reviewingTranslations[] = $translation;
402
-        }
403
-
404
-        /* @var $article2 DDC117Article */
405
-        $article2 = $this->_em->find(get_class($this->article2), $this->article2->id());
406
-        $article2->addTranslation("de", "Vanille-Krapferl"); // omnomnom
407
-        $article2->addTranslation("fr", "Sorry can't speak french!");
408
-
409
-        foreach ($article2->getTranslations() AS $translation) {
410
-            $this->_em->persist($translation); // otherwise persisting the editor won't work, reachability!
411
-            $editor->reviewingTranslations[] = $translation;
412
-        }
413
-
414
-        $this->_em->persist($editor);
415
-        $this->_em->flush();
416
-        $this->_em->clear();
417
-
418
-        return $this->_em->find(get_class($editor), $editor->id);
419
-    }
420
-
421
-    /**
422
-     * @group DDC-1519
423
-     */
424
-    public function testMergeForeignKeyIdentifierEntity()
425
-    {
426
-        $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id());
427
-
428
-        $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria);
429
-
430
-        $this->_em->detach($refRep);
431
-        $refRep = $this->_em->merge($refRep);
432
-
433
-        $this->assertEquals($this->article1->id(), $refRep->source()->id());
434
-        $this->assertEquals($this->article2->id(), $refRep->target()->id());
435
-    }
436
-
437
-    /**
438
-     * @group DDC-1652
439
-     */
440
-    public function testArrayHydrationWithCompositeKey()
441
-    {
442
-        $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t";
443
-        $before = count($this->_em->createQuery($dql)->getResult());
444
-
445
-        $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id());
446
-        $this->article2 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article2->id());
447
-
448
-        $this->reference = new DDC117Reference($this->article2, $this->article1, "Test-Description");
449
-        $this->_em->persist($this->reference);
450
-
451
-        $this->reference = new DDC117Reference($this->article1, $this->article1, "Test-Description");
452
-        $this->_em->persist($this->reference);
453
-
454
-        $this->reference = new DDC117Reference($this->article2, $this->article2, "Test-Description");
455
-        $this->_em->persist($this->reference);
456
-
457
-        $this->_em->flush();
458
-
459
-        $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t";
460
-        $data = $this->_em->createQuery($dql)->getArrayResult();
461
-
462
-        $this->assertEquals($before + 3, count($data));
463
-    }
464
-}

File diff suppressed because it is too large
+ 0 - 1098
vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php


+ 0 - 142
vendor/gedmo/doctrine-extensions/README.md View File

@@ -1,142 +0,0 @@
1
-# Doctrine2 behavioral extensions
2
-
3
-## I'm looking for maintainers of this project
4
-
5
-Feel free to open discusion in issue or email message if you are interested in maintaining,
6
-refactoring doctrine2 extensions. The repository can be moved to the maintainers account and fork
7
-left on mine. I do not want users to lose availability of stable extensions which they were and are
8
-used to, at the moment.
9
-
10
-**Version 2.3.5**
11
-
12
-[![Build Status](https://secure.travis-ci.org/l3pp4rd/DoctrineExtensions.png?branch=master)](http://travis-ci.org/l3pp4rd/DoctrineExtensions)
13
-
14
-**Note:** recently doctrine orm and odm were updated to use common doctrine mapping persistense
15
-layer. The support for it has been made and tagged with **2.3.1** version tag. It will be compatible
16
-with latest version of doctrine mapping at master branches
17
-
18
-### Latest updates
19
-
20
-**2013-03-05**
21
-
22
-- A new extension - **References**, which links Entities in Documents and visa versa, [read more about it](https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/references.md). It was contributed by @jwage, @avalanche123, @jmikola and @bobthecow, thanks
23
-
24
-**2013-02-05**
25
-
26
-- **Sluggable** added back slug handler mapping driver support for yaml and xml.
27
-
28
-**2012-12-06**
29
-
30
-- **Blameable** extension added to allow setting a username string or user object on fields, with the same options as Timestampable.
31
-
32
-
33
-**2012-07-05**
34
-
35
-- **Mapping** drivers were updated to support latest doctrine versions.
36
-
37
-**2012-05-01**
38
-
39
-- **Sluggable** now allows to regenerate slug if its set to empty or null. Also it allows to
40
-manually set the slug, in that case it would only transliterate it and ensure uniqueness.
41
-
42
-### Summary and features
43
-
44
-This package contains extensions for Doctrine2 that hook into the facilities of Doctrine and
45
-offer new functionality or tools to use Doctrine2 more efficently. This package contains mostly
46
-used behaviors which can be easily attached to your event system of Doctrine2 and handle the
47
-records being flushed in the behavioral way. List of extensions:
48
-
49
-- **Tree** - this extension automates the tree handling process and adds some tree specific functions on repository.
50
-(**closure**, **nestedset** or **materialized path**)
51
-- **Translatable** - gives you a very handy solution for translating records into diferent languages. Easy to setup, easier to use.
52
-- **Sluggable** - urlizes your specified fields into single unique slug
53
-- **Timestampable** - updates date fields on create, update and even property change.
54
-- **Blameable** - updates string or reference fields on create, update and even property change with a string or object (e.g. user).
55
-- **Loggable** - helps tracking changes and history of objects, also supports version managment.
56
-- **Sortable** - makes any document or entity sortable
57
-- **Translator** - explicit way to handle translations
58
-- **Softdeleteable** - allows to implicitly remove records
59
-- **Uploadable** - provides file upload handling in entity fields
60
-- **References** - supports linking Entities in Documents and visa versa
61
-
62
-Currently these extensions support **Yaml**, **Annotation**  and **Xml** mapping. Additional mapping drivers
63
-can be easily implemented using Mapping extension to handle the additional metadata mapping.
64
-
65
-**Note:** Please note, that xml mapping needs to be in a different namespace, the declared namespace for
66
-Doctrine extensions is http://gediminasm.org/schemas/orm/doctrine-extensions-mapping
67
-So root node now looks like this:
68
-
69
-**Note:** Use 2.1.x tag in order to use extensions based on Doctrine2.1.x versions. Currently
70
-master branch is based on 2.2.x versions and may not work with 2.1.x
71
-
72
-```
73
-<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
74
-                 xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
75
-...
76
-</doctrine-mapping>
77
-```
78
-
79
-XML mapping xsd schemas are also versioned and can be used by version suffix:
80
-
81
-- Latest version - **http://gediminasm.org/schemas/orm/doctrine-extensions-mapping**
82
-- 2.2.x version - **http://gediminasm.org/schemas/orm/doctrine-extensions-mapping-2-2**
83
-- 2.1.x version - **http://gediminasm.org/schemas/orm/doctrine-extensions-mapping-2-1**
84
-
85
-### ODM MongoDB support
86
-
87
-List of extensions which support ODM
88
-
89
-- Translatable
90
-- Sluggable
91
-- Timestampable
92
-- Blameable
93
-- Loggable
94
-- Translator
95
-- Tree (Materialized Path strategy for now)
96
-- References
97
-
98
-All these extensions can be nested together and mapped in traditional ways - annotations,
99
-xml or yaml
100
-
101
-You can test these extensions on [my blog](http://gediminasm.org/demo "Test doctrine behavioral extensions").
102
-All tutorials for basic usage examples are on [my blog](http://gediminasm.org "Tutorials for extensions") too.
103
-You can also fork or clone this blog from [github repository](https://github.com/l3pp4rd/gediminasm.org)
104
-
105
-### Running the tests:
106
-
107
-PHPUnit 3.6 or newer is required.
108
-To setup and run tests follow these steps:
109
-
110
-- go to the root directory of extensions
111
-- download composer: **wget https://getcomposer.org/composer.phar**
112
-- install dev libraries: **php composer.phar install --dev**
113
-- run: **phpunit -c tests**
114
-- optional - run mongodb service if targetting mongo tests
115
-
116
-<a name="example-demo"></a>
117
-
118
-### Running the example:
119
-
120
-To setup and run example follow these steps:
121
-
122
-- go to the root directory of extensions
123
-- download composer: **wget https://getcomposer.org/composer.phar**
124
-- install dev libraries: **php composer.phar install --dev**
125
-- edit **example/em.php** and configure your database on top of the file
126
-- run: **./example/bin/console** or **php example/bin/console** for console commands
127
-- run: **./example/bin/console orm:schema-tool:create** to create schema
128
-- run: **php example/run.php** to run example
129
-
130
-### Contributors:
131
-
132
-Thanks to [everyone participating](http://github.com/l3pp4rd/DoctrineExtensions/contributors) in
133
-the development of these great Doctrine2 extensions!
134
-
135
-And especialy ones who create and maintain new extensions:
136
-
137
-- Lukas Botsch [lbotsch](http://github.com/lbotsch)
138
-- Gustavo Adrian [comfortablynumb](http://github.com/comfortablynumb)
139
-- Boussekeyt Jules [gordonslondon](http://github.com/gordonslondon)
140
-- Kudryashov Konstantin [everzet](http://github.com/everzet)
141
-- David Buchmann [dbu](https://github.com/dbu)
142
-

+ 0 - 219
vendor/gedmo/doctrine-extensions/doc/references.md View File

@@ -1,219 +0,0 @@
1
-# Cross Object Mapper References behavior extension for Doctrine 2
2
-
3
-Create documents and entities that contain references to each other.
4
-
5
-## Options
6
-
7
-The following options are possible on reference one and many associations:
8
-
9
-**Owning Side**
10
-
11
-- **type** - The type of association.
12
-- **class** - The associated class name.
13
-- **inversedBy** - The property name for the inverse side of this association.
14
-- **identifier** - The property name to store the associated object id in.
15
-
16
-**Inverse Side**
17
-
18
-- **type** - The type of association.
19
-- **class** - The associated class name.
20
-- **mappedBy** - The property name for the owning side of this association.
21
-
22
-## Annotations
23
-
24
-**@Gedmo\ReferenceOne**
25
-
26
-``` php
27
-<?php
28
-
29
-/**
30
- * @Gedmo\ReferenceMany(type="entity", class="Entity\StockItem", mappedBy="product")
31
- */
32
-private $stockItems;
33
-```
34
-
35
-**@Gedmo\ReferenceMany**
36
-
37
-``` php
38
-<?php
39
-
40
-/**
41
- * @Gedmo\ReferenceOne(type="document", class="Document\Product", inversedBy="stockItems", identifier="productId")
42
- */
43
-private $product;
44
-```
45
-
46
-## Example
47
-
48
-Here is an example where you have a Product which is mapped using the Doctrine MongoDB ODM project and it contains a property `$stockItems` that is populated from the Doctrine2 ORM.
49
-
50
-``` php
51
-<?php
52
-
53
-namespace Document;
54
-
55
-use Doctrine\Common\Collections\Collection;
56
-use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
57
-use Gedmo\Mapping\Annotation as Gedmo;
58
-
59
-/**
60
- * @ODM\Document
61
- */
62
-class Product
63
-{
64
-    /**
65
-     * @ODM\Id
66
-     */
67
-    private $id;
68
-
69
-    /**
70
-     * @ODM\String
71
-     */
72
-    private $name;
73
-
74
-    /**
75
-     * @Gedmo\ReferenceMany(type="entity", class="Entity\StockItem", mappedBy="product")
76
-     */
77
-    private $stockItems;
78
-
79
-    public function getId()
80
-    {
81
-        return $this->id;
82
-    }
83
-
84
-    public function setId($id)
85
-    {
86
-        $this->id = $id;
87
-    }
88
-
89
-    public function getName()
90
-    {
91
-        return $this->name;
92
-    }
93
-
94
-    public function setName($name)
95
-    {
96
-        $this->name = $name;
97
-    }
98
-
99
-    public function getStockItems()
100
-    {
101
-        return $this->stockItems;
102
-    }
103
-
104
-    public function setStockItems(Collection $stockItems)
105
-    {
106
-        $this->stockItems = $stockItems;
107
-    }
108
-}
109
-```
110
-
111
-The `StockItem` has a reference to the `Product` as well.
112
-
113
-``` php
114
-<?php
115
-
116
-namespace Entity;
117
-
118
-use Doctrine\ORM\Mapping as ORM;
119
-use Gedmo\Mapping\Annotation as Gedmo;
120
-use References\Fixture\ODM\MongoDB\Product;
121
-
122
-/**
123
- * @ORM\Entity
124
- */
125
-class StockItem
126
-{
127
-    /**
128
-     * @ORM\Id
129
-     * @ORM\Column(type="integer")
130
-     * @ORM\GeneratedValue(strategy="IDENTITY")
131
-     */
132
-    private $id;
133
-
134
-    /**
135
-     * @ORM\Column
136
-     */
137
-    private $name;
138
-
139
-    /**
140
-     * @ORM\Column
141
-     */
142
-    private $sku;
143
-
144
-    /**
145
-     * @ORM\Column(type="integer")
146
-     */
147
-    private $quantity;
148
-
149
-    /**
150
-     * @Gedmo\ReferenceOne(type="document", class="Document\Product", inversedBy="stockItems", identifier="productId")
151
-     */
152
-    private $product;
153
-
154
-    /**
155
-     * @ORM\Column(type="string")
156
-     */
157
-    private $productId;
158
-
159
-    public function getId()
160
-    {
161
-        return $this->id;
162
-    }
163
-
164
-    public function setId($id)
165
-    {
166
-        $this->id = $id;
167
-    }
168
-
169
-    public function getName()
170
-    {
171
-        return $this->name;
172
-    }
173
-
174
-    public function setName($name)
175
-    {
176
-        $this->name = $name;
177
-    }
178
-
179
-    public function getSku()
180
-    {
181
-        return $this->sku;
182
-    }
183
-
184
-    public function setSku($sku)
185
-    {
186
-        $this->sku = $sku;
187
-    }
188
-
189
-    public function getQuantity()
190
-    {
191
-        return $this->quantity;
192
-    }
193
-
194
-    public function setQuantity($quantity)
195
-    {
196
-        $this->quantity = $quantity;
197
-    }
198
-
199
-    public function setProduct(Product $product)
200
-    {
201
-        $this->product = $product;
202
-    }
203
-
204
-    public function getProduct()
205
-    {
206
-        return $this->product;
207
-    }
208
-
209
-    public function setProductId($productId)
210
-    {
211
-        $this->productId = $productId;
212
-    }
213
-
214
-    public function getProductId()
215
-    {
216
-        return $this->productId;
217
-    }
218
-}
219
-```

File diff suppressed because it is too large
+ 0 - 1265
vendor/gedmo/doctrine-extensions/doc/tree.md


+ 0 - 95
vendor/gedmo/doctrine-extensions/lib/Gedmo/Blameable/BlameableListener.php View File

@@ -1,95 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Blameable;
4
-
5
-use Doctrine\Common\EventArgs;
6
-use Doctrine\Common\NotifyPropertyChanged;
7
-use Gedmo\Exception\InvalidArgumentException;
8
-use Gedmo\Mapping\MappedEventSubscriber;
9
-use Gedmo\Timestampable\TimestampableListener;
10
-use Gedmo\Blameable\Mapping\Event\BlameableAdapter;
11
-
12
-/**
13
- * The Blameable listener handles the update of
14
- * dates on creation and update.
15
- *
16
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
17
- * @package Gedmo.Blameable
18
- * @subpackage BlameableListener
19
- * @link http://www.gediminasm.org
20
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
21
- */
22
-class BlameableListener extends TimestampableListener
23
-{
24
-    protected $user;
25
-
26
-    /**
27
-     * Get the user value to set on a blameable field
28
-     *
29
-     * @param object $meta
30
-     * @param string $field
31
-     * @return mixed
32
-     */
33
-    public function getUserValue($meta, $field)
34
-    {
35
-        if ($meta->hasAssociation($field)) {
36
-            if (null !== $this->user && ! is_object($this->user)) {
37
-                throw new InvalidArgumentException("Blame is reference, user must be an object");
38
-            }
39
-
40
-            return $this->user;
41
-        }
42
-
43
-        // ok so its not an association, then it is a string
44
-        if (is_object($this->user)) {
45
-            if (method_exists($this->user, 'getUsername')) {
46
-                return (string)$this->user->getUsername();
47
-            }
48
-            if (method_exists($this->user, '__toString')) {
49
-                return $this->user->__toString();
50
-            }
51
-            throw new InvalidArgumentException("Field expects string, user must be a string, or object should have method getUsername or __toString");
52
-        }
53
-
54
-        return $this->user;
55
-    }
56
-
57
-    /**
58
-     * Set a user value to return
59
-     *
60
-     * @return mixed
61
-     */
62
-    public function setUserValue($user)
63
-    {
64
-        $this->user = $user;
65
-    }
66
-
67
-    /**
68
-     * {@inheritDoc}
69
-     */
70
-    protected function getNamespace()
71
-    {
72
-        return __NAMESPACE__;
73
-    }
74
-
75
-    /**
76
-     * Updates a field
77
-     *
78
-     * @param mixed $object
79
-     * @param BlameableAdapter $ea
80
-     * @param $meta
81
-     * @param $field
82
-     */
83
-    protected function updateField($object, $ea, $meta, $field)
84
-    {
85
-        $property = $meta->getReflectionProperty($field);
86
-        $oldValue = $property->getValue($object);
87
-        $newValue = $this->getUserValue($meta, $field);
88
-
89
-        $property->setValue($object, $newValue);
90
-        if ($object instanceof NotifyPropertyChanged) {
91
-            $uow = $ea->getObjectManager()->getUnitOfWork();
92
-            $uow->propertyChanged($object, $field, $oldValue, $newValue);
93
-        }
94
-    }
95
-}

+ 0 - 25
vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/Reference.php View File

@@ -1,25 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Mapping\Annotation;
4
-
5
-use Doctrine\Common\Annotations\Annotation;
6
-
7
-/**
8
- * Reference annotation for ORM -> ODM references extension
9
- * to be user like @ReferenceMany(type="entity", class="MyEntity", identifier="entity_id")
10
- *
11
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
12
- * @package Gedmo.Mapping.Annotation
13
- * @subpackage Language
14
- * @link http://www.gediminasm.org
15
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16
- * @Annotation
17
- */
18
-abstract class Reference extends Annotation
19
-{
20
-    public $type;
21
-    public $class;
22
-    public $identifier;
23
-    public $mappedBy;
24
-    public $inversedBy;
25
-}

+ 0 - 21
vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/ReferenceMany.php View File

@@ -1,21 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Mapping\Annotation;
4
-
5
-use Doctrine\Common\Annotations\Annotation;
6
-
7
-/**
8
- * Reference annotation for ORM -> ODM references extension
9
- * to be user like @ReferenceOne(type="entity", class="MyEntity", identifier="entity_id")
10
- *
11
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
12
- * @package Gedmo.Mapping.Annotation
13
- * @subpackage Language
14
- * @link http://www.gediminasm.org
15
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16
- * @Annotation
17
- */
18
-class ReferenceMany extends Reference
19
-{
20
-}
21
-

+ 0 - 21
vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/ReferenceOne.php View File

@@ -1,21 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Mapping\Annotation;
4
-
5
-use Doctrine\Common\Annotations\Annotation;
6
-
7
-/**
8
- * Reference annotation for ORM -> ODM references extension
9
- * to be user like @ReferenceOne(type="entity", class="MyEntity", identifier="entity_id")
10
- *
11
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
12
- * @package Gedmo.Mapping.Annotation
13
- * @subpackage Language
14
- * @link http://www.gediminasm.org
15
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16
- * @Annotation
17
- */
18
-class ReferenceOne extends Reference
19
-{
20
-}
21
-

+ 0 - 31
vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/TreePath.php View File

@@ -1,31 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Mapping\Annotation;
4
-
5
-use Doctrine\Common\Annotations\Annotation;
6
-
7
-/**
8
- * TreePath annotation for Tree behavioral extension
9
- *
10
- * @Annotation
11
- * @Target("PROPERTY")
12
- *
13
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
14
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
15
- * @author <rocco@roccosportal.com>
16
- * @package Gedmo.Mapping.Annotation
17
- * @subpackage TreePath
18
- * @link http://www.gediminasm.org
19
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
20
- */
21
-final class TreePath extends Annotation
22
-{
23
-    public $separator = ',';
24
-
25
-    public $appendId = null;
26
-
27
-    public $startsWithSeparator = false;
28
-
29
-    public $endsWithSeparator = true;
30
-}
31
-

+ 0 - 22
vendor/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/TreePathHash.php View File

@@ -1,22 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Mapping\Annotation;
4
-
5
-use Doctrine\Common\Annotations\Annotation;
6
-
7
-/**
8
- * TreePath annotation for Tree behavioral extension
9
- *
10
- * @Annotation
11
- * @Target("PROPERTY")
12
- *
13
- * @author <rocco@roccosportal.com>
14
- * @package Gedmo.Mapping.Annotation
15
- * @subpackage TreePathHash
16
- * @link http://www.gediminasm.org
17
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
18
- */
19
-final class TreePathHash extends Annotation
20
-{
21
-
22
-}

+ 0 - 215
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/LazyCollection.php View File

@@ -1,215 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References;
4
-
5
-use Doctrine\Common\Collections\ArrayCollection;
6
-
7
-use Doctrine\Common\Collections\Collection;
8
-
9
-/**
10
- * Lazy collection for loading reference many associations.
11
- *
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
14
- * @author Jonathan H. Wage <jonwage@gmail.com>
15
- * @package Gedmo\References\Mapping\Event
16
- * @link http://www.gediminasm.org
17
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
18
- */
19
-class LazyCollection implements Collection
20
-{
21
-    private $results;
22
-    private $callback;
23
-
24
-    public function __construct($callback)
25
-    {
26
-        $this->callback = $callback;
27
-    }
28
-
29
-    public function add($element)
30
-    {
31
-        $this->initialize();
32
-        return $this->results->add($element);
33
-    }
34
-
35
-    public function clear()
36
-    {
37
-        $this->initialize();
38
-        return $this->results->clear();
39
-    }
40
-
41
-    public function contains($element)
42
-    {
43
-        $this->initialize();
44
-        return $this->results->contains($element);
45
-    }
46
-
47
-    public function containsKey($key)
48
-    {
49
-        $this->initialize();
50
-        return $this->results->containsKey($key);
51
-    }
52
-
53
-    public function current()
54
-    {
55
-        $this->initialize();
56
-        return $this->results->current();
57
-    }
58
-
59
-    public function exists(\Closure $p)
60
-    {
61
-        $this->initialize();
62
-        return $this->results->exists($p);
63
-    }
64
-
65
-    public function filter(\Closure $p)
66
-    {
67
-        $this->initialize();
68
-        return $this->results->filter($p);
69
-    }
70
-
71
-    public function first()
72
-    {
73
-        $this->initialize();
74
-        return $this->results->first();
75
-    }
76
-
77
-    public function forAll(\Closure $p)
78
-    {
79
-        $this->initialize();
80
-        return $this->results->forAll($p);
81
-    }
82
-
83
-    public function get($key)
84
-    {
85
-        $this->initialize();
86
-        return $this->results->get($key);
87
-    }
88
-
89
-    public function getKeys()
90
-    {
91
-        $this->initialize();
92
-        return $this->results->getKeys();
93
-    }
94
-
95
-    public function getValues()
96
-    {
97
-        $this->initialize();
98
-        return $this->results->getValues();
99
-    }
100
-
101
-    public function indexOf($element)
102
-    {
103
-        $this->initialize();
104
-        return $this->results->indexOf($element);
105
-    }
106
-
107
-    public function isEmpty()
108
-    {
109
-        $this->initialize();
110
-        return $this->results->isEmpty();
111
-    }
112
-
113
-    public function key()
114
-    {
115
-        $this->initialize();
116
-        return $this->results->key();
117
-    }
118
-
119
-    public function last()
120
-    {
121
-        $this->initialize();
122
-        return $this->results->last();
123
-    }
124
-
125
-    public function map(\Closure $func)
126
-    {
127
-        $this->initialize();
128
-        return $this->results->map($func);
129
-    }
130
-
131
-    public function next()
132
-    {
133
-        $this->initialize();
134
-        return $this->results->next();
135
-    }
136
-
137
-    public function partition(\Closure $p)
138
-    {
139
-        $this->initialize();
140
-        return $this->results->partition($p);
141
-    }
142
-
143
-    public function remove($key)
144
-    {
145
-        $this->initialize();
146
-        return $this->results->remove($key);
147
-    }
148
-
149
-    public function removeElement($element)
150
-    {
151
-        $this->initialize();
152
-        return $this->results->removeElement($element);
153
-    }
154
-
155
-    public function set($key, $value)
156
-    {
157
-        $this->initialize();
158
-        return $this->results->set($key, $value);
159
-    }
160
-
161
-    public function slice($offset, $length = null)
162
-    {
163
-        $this->initialize();
164
-        return $this->results->slice($offset, $length);
165
-    }
166
-
167
-    public function toArray()
168
-    {
169
-        $this->initialize();
170
-        return $this->results->toArray();
171
-    }
172
-
173
-    public function offsetExists($offset)
174
-    {
175
-        $this->initialize();
176
-        return $this->results->offsetExists($offset);
177
-    }
178
-
179
-    public function offsetGet($offset)
180
-    {
181
-        $this->initialize();
182
-        return $this->results->offsetGet($offset);
183
-    }
184
-
185
-    public function offsetSet($offset, $value)
186
-    {
187
-        $this->initialize();
188
-        return $this->results->offsetSet($offset, $value);
189
-    }
190
-
191
-    public function offsetUnset($offset)
192
-    {
193
-        $this->initialize();
194
-        return $this->results->offsetUnset($offset);
195
-    }
196
-
197
-    public function getIterator()
198
-    {
199
-        $this->initialize();
200
-        return $this->results->getIterator();
201
-    }
202
-
203
-    public function count()
204
-    {
205
-        $this->initialize();
206
-        return $this->results->count();
207
-    }
208
-
209
-    private function initialize()
210
-    {
211
-        if (null === $this->results) {
212
-            $this->results = call_user_func($this->callback);
213
-        }
214
-    }
215
-}

+ 0 - 99
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Driver/Annotation.php View File

@@ -1,99 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\AnnotationDriverInterface,
6
-    Doctrine\Common\Annotations\AnnotationReader,
7
-    Doctrine\Common\Persistence\Mapping\ClassMetadata,
8
-    Gedmo\Exception\InvalidMappingException;
9
-
10
-/**
11
- * This is an annotation mapping driver for References
12
- * behavioral extension.
13
- *
14
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
15
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
16
- * @author Jonathan H. Wage <jonwage@gmail.com>
17
- * @package Gedmo.References.Mapping.Driver
18
- * @subpackage Annotation
19
- * @link http://www.gediminasm.org
20
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
21
- */
22
-class Annotation implements AnnotationDriverInterface
23
-{
24
-    /**
25
-     * Annotation to mark field as reference to one
26
-     */
27
-    const REFERENCE_ONE = 'Gedmo\\Mapping\\Annotation\\ReferenceOne';
28
-
29
-    /**
30
-     * Annotation to mark field as reference to many
31
-     */
32
-    const REFERENCE_MANY = 'Gedmo\\Mapping\\Annotation\\ReferenceMany';
33
-
34
-    private $annotations = array(
35
-        'referenceOne'  => self::REFERENCE_ONE,
36
-        'referenceMany' => self::REFERENCE_MANY,
37
-    );
38
-
39
-    /**
40
-     * Annotation reader instance
41
-     *
42
-     * @var object
43
-     */
44
-    private $reader;
45
-
46
-    /**
47
-     * original driver if it is available
48
-     */
49
-    protected $_originalDriver = null;
50
-
51
-    /**
52
-     * {@inheritDoc}
53
-     */
54
-    public function setAnnotationReader($reader)
55
-    {
56
-        $this->reader = $reader;
57
-    }
58
-
59
-    /**
60
-     * {@inheritDoc}
61
-     */
62
-    public function readExtendedMetadata($meta, array &$config)
63
-    {
64
-        $class = $meta->getReflectionClass();
65
-        foreach($this->annotations as $key => $annotation) {
66
-            $config[$key] = array();
67
-            foreach ($class->getProperties() as $property) {
68
-                if ($meta->isMappedSuperclass && !$property->isPrivate() ||
69
-                    $meta->isInheritedField($property->name) ||
70
-                    isset($meta->associationMappings[$property->name]['inherited'])
71
-                ) {
72
-                    continue;
73
-                }
74
-
75
-                if ($reference = $this->reader->getPropertyAnnotation($property, $annotation)) {
76
-                    $config[$key][$property->getName()] = array(
77
-                        'field'      => $property->getName(),
78
-                        'type'       => $reference->type,
79
-                        'class'      => $reference->class,
80
-                        'identifier' => $reference->identifier,
81
-                        'mappedBy'   => $reference->mappedBy,
82
-                        'inversedBy' => $reference->inversedBy,
83
-                    );
84
-                }
85
-            }
86
-        }
87
-    }
88
-
89
-    /**
90
-     * Passes in the mapping read by original driver
91
-     *
92
-     * @param $driver
93
-     * @return void
94
-     */
95
-    public function setOriginalDriver($driver)
96
-    {
97
-        $this->_originalDriver = $driver;
98
-    }
99
-}

+ 0 - 99
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/Adapter/ODM.php View File

@@ -1,99 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References\Mapping\Event\Adapter;
4
-
5
-use Doctrine\Common\Persistence\ObjectManager;
6
-use Doctrine\ODM\MongoDB\DocumentManager;
7
-use Doctrine\ODM\MongoDB\Proxy\Proxy as MongoDBProxy;
8
-use Doctrine\ORM\EntityManager;
9
-use Doctrine\ORM\Proxy\Proxy as ORMProxy;
10
-use Gedmo\Exception\InvalidArgumentException;
11
-use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
12
-use Gedmo\References\Mapping\Event\ReferencesAdapter;
13
-
14
-/**
15
- * Doctrine event adapter for ODM references behavior
16
- *
17
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
18
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
19
- * @author Jonathan H. Wage <jonwage@gmail.com>
20
- * @package Gedmo\References\Mapping\Event\Adapter
21
- * @subpackage ODM
22
- * @link http://www.gediminasm.org
23
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
24
- */
25
-final class ODM extends BaseAdapterODM implements ReferencesAdapter
26
-{
27
-    /**
28
-     * @inheritDoc
29
-     */
30
-    public function getIdentifier($om, $object, $single = true)
31
-    {
32
-        if ($om instanceof DocumentManager) {
33
-            return $this->extractIdentifier($om, $object, $single);
34
-        }
35
-
36
-        if ($om instanceof EntityManager) {
37
-            if ($object instanceof ORMProxy) {
38
-                $id = $om->getUnitOfWork()->getEntityIdentifier($object);
39
-            } else {
40
-                $meta = $om->getClassMetadata(get_class($object));
41
-                $id = array();
42
-                foreach ($meta->identifier as $name) {
43
-                    $id[$name] = $meta->getReflectionProperty($name)->getValue($object);
44
-                    // return null if one of identifiers is missing
45
-                    if (!$id[$name]) {
46
-                        return null;
47
-                    }
48
-                }
49
-            }
50
-
51
-            if ($single) {
52
-                $id = current($id);
53
-            }
54
-
55
-            return $id;
56
-        }
57
-    }
58
-
59
-    /**
60
-     * @inheritDoc
61
-     */
62
-    public function getSingleReference($om, $class, $identifier)
63
-    {
64
-        $this->throwIfNotEntityManager($om);
65
-        $meta = $om->getClassMetadata($class);
66
-
67
-        if (!$meta->isInheritanceTypeNone()) {
68
-            return $om->find($class, $identifier);
69
-        }
70
-
71
-        return $om->getReference($class, $identifier);
72
-    }
73
-
74
-    /**
75
-     * @inheritDoc
76
-     */
77
-    public function extractIdentifier($om, $object, $single = true)
78
-    {
79
-        $meta = $om->getClassMetadata(get_class($object));
80
-        if ($object instanceof MongoDBProxy) {
81
-            $id = $om->getUnitOfWork()->getDocumentIdentifier($object);
82
-        } else {
83
-            $id = $meta->getReflectionProperty($meta->identifier)->getValue($object);
84
-        }
85
-
86
-        if ($single || !$id) {
87
-            return $id;
88
-        } else {
89
-            return array($meta->identifier => $id);
90
-        }
91
-    }
92
-
93
-    /**
94
-     * Override so we don't get an exception. We want to allow this.
95
-     */
96
-    private function throwIfNotEntityManager(EntityManager $em)
97
-    {
98
-    }
99
-}

+ 0 - 98
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/Adapter/ORM.php View File

@@ -1,98 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References\Mapping\Event\Adapter;
4
-
5
-use Doctrine\Common\Persistence\ObjectManager;
6
-use Doctrine\ODM\MongoDB\DocumentManager;
7
-use Doctrine\ODM\MongoDB\Proxy\Proxy as MongoDBProxy;
8
-use Doctrine\ORM\EntityManager;
9
-use Doctrine\ORM\Proxy\Proxy as ORMProxy;
10
-use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
11
-use Gedmo\References\Mapping\Event\ReferencesAdapter;
12
-
13
-/**
14
- * Doctrine event adapter for ORM references behavior
15
- *
16
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
17
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
18
- * @author Jonathan H. Wage <jonwage@gmail.com>
19
- * @package Gedmo\References\Mapping\Event\Adapter
20
- * @subpackage ORM
21
- * @link http://www.gediminasm.org
22
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
23
- */
24
-final class ORM extends BaseAdapterORM implements ReferencesAdapter
25
-{
26
-    /**
27
-     * @inheritDoc
28
-     */
29
-    public function getIdentifier($om, $object, $single = true)
30
-    {
31
-        if ($om instanceof EntityManager) {
32
-            return $this->extractIdentifier($om, $object, $single);
33
-        }
34
-
35
-        if ($om instanceof DocumentManager) {
36
-            $meta = $om->getClassMetadata(get_class($object));
37
-            if ($object instanceof MongoDBProxy) {
38
-                $id = $om->getUnitOfWork()->getDocumentIdentifier($object);
39
-            } else {
40
-                $id = $meta->getReflectionProperty($meta->identifier)->getValue($object);
41
-            }
42
-
43
-            if ($single || !$id) {
44
-                return $id;
45
-            }
46
-
47
-            return array($meta->identifier => $id);
48
-        }
49
-    }
50
-
51
-    /**
52
-     * @inheritDoc
53
-     */
54
-    public function getSingleReference($om, $class, $identifier)
55
-    {
56
-        $this->throwIfNotDocumentManager($om);
57
-        $meta = $om->getClassMetadata($class);
58
-
59
-        if (!$meta->isInheritanceTypeNone()) {
60
-            return $om->find($class, $identifier);
61
-        }
62
-
63
-        return $om->getReference($class, $identifier);
64
-    }
65
-
66
-    /**
67
-     * @inheritDoc
68
-     */
69
-    public function extractIdentifier($om, $object, $single = true)
70
-    {
71
-        if ($object instanceof ORMProxy) {
72
-            $id = $om->getUnitOfWork()->getEntityIdentifier($object);
73
-        } else {
74
-            $meta = $om->getClassMetadata(get_class($object));
75
-            $id = array();
76
-            foreach ($meta->identifier as $name) {
77
-                $id[$name] = $meta->getReflectionProperty($name)->getValue($object);
78
-                // return null if one of identifiers is missing
79
-                if (!$id[$name]) {
80
-                    return null;
81
-                }
82
-            }
83
-        }
84
-
85
-        if ($single) {
86
-            $id = current($id);
87
-        }
88
-
89
-        return $id;
90
-    }
91
-
92
-    /**
93
-     * Override so we don't get an exception. We want to allow this.
94
-     */
95
-    private function throwIfNotDocumentManager(DocumentManager $dm)
96
-    {
97
-    }
98
-}

+ 0 - 50
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/Mapping/Event/ReferencesAdapter.php View File

@@ -1,50 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References\Mapping\Event;
4
-
5
-use Doctrine\Common\Persistence\Mapping\ClassMetadata;
6
-use Doctrine\Common\Persistence\ObjectManager;
7
-use Gedmo\Mapping\Event\AdapterInterface;
8
-
9
-/**
10
- * Doctrine event adapter interface for References behavior
11
- *
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
14
- * @author Jonathan H. Wage <jonwage@gmail.com>
15
- * @package Gedmo\References\Mapping\Event
16
- * @subpackage ReferencesAdapter
17
- * @link http://www.gediminasm.org
18
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
19
- */
20
-interface ReferencesAdapter extends AdapterInterface
21
-{
22
-    /**
23
-     * Gets the identifier of the given object using the passed ObjectManager.
24
-     *
25
-     * @param ObjectManager $om
26
-     * @param object $object
27
-     * @param bool $single
28
-     * @return array|scalar $id - array or single identifier
29
-     */
30
-    function getIdentifier($om, $object, $single = true);
31
-
32
-    /**
33
-     * Gets a single reference for the given ObjectManager, class and identifier.
34
-     *
35
-     * @param ObjectManager $om
36
-     * @param string $class
37
-     * @param array|scalar $identifier
38
-     **/
39
-    function getSingleReference($om, $class, $identifier);
40
-
41
-    /**
42
-     * Extracts identifiers from object or proxy.
43
-     *
44
-     * @param DocumentManager $om
45
-     * @param object $object
46
-     * @param bool $single
47
-     * @return array|scalar - array or single identifier
48
-     */
49
-    function extractIdentifier($om, $object, $single = true);
50
-}

+ 0 - 158
vendor/gedmo/doctrine-extensions/lib/Gedmo/References/ReferencesListener.php View File

@@ -1,158 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References;
4
-
5
-use Doctrine\Common\Collections\ArrayCollection;
6
-use Doctrine\Common\EventArgs;
7
-use Doctrine\ORM\Mapping\ClassMetadata as ORMClassMetadata;
8
-use Doctrine\ORM\EntityManager;
9
-use Doctrine\ODM\MongoDB\DocumentManager;
10
-use Doctrine\ODM\MongoDB\Mapping\ClassMetadata as MongoDBClassMetadata;
11
-use Gedmo\Exception\InvalidArgumentException;
12
-use Gedmo\Mapping\MappedEventSubscriber;
13
-
14
-/**
15
- * Listener for loading and persisting cross database references.
16
- *
17
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
18
- * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
19
- * @author Jonathan H. Wage <jonwage@gmail.com>
20
- * @package Gedmo\References\Mapping\Event
21
- * @subpackage MappedEventSubscriber
22
- * @link http://www.gediminasm.org
23
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
24
- */
25
-class ReferencesListener extends MappedEventSubscriber
26
-{
27
-    private $managers;
28
-
29
-    public function __construct(array $managers = array())
30
-    {
31
-        $this->managers = $managers;
32
-    }
33
-
34
-    public function loadClassMetadata(EventArgs $eventArgs)
35
-    {
36
-        $ea = $this->getEventAdapter($eventArgs);
37
-        $this->loadMetadataForObjectClass(
38
-            $ea->getObjectManager(), $eventArgs->getClassMetadata()
39
-        );
40
-    }
41
-
42
-    public function postLoad(EventArgs $eventArgs)
43
-    {
44
-        $ea = $this->getEventAdapter($eventArgs);
45
-        $om = $ea->getObjectManager();
46
-        $object = $ea->getObject();
47
-        $meta = $om->getClassMetadata(get_class($object));
48
-        $config = $this->getConfiguration($om, $meta->name);
49
-        foreach ($config['referenceOne'] as $mapping) {
50
-            $property = $meta->reflClass->getProperty($mapping['field']);
51
-            $property->setAccessible(true);
52
-            if (isset($mapping['identifier'])) {
53
-                $referencedObjectId = $meta->getFieldValue($object, $mapping['identifier']);
54
-                if (null !== $referencedObjectId) {
55
-                    $property->setValue(
56
-                        $object,
57
-                        $ea->getSingleReference(
58
-                            $this->getManager($mapping['type']),
59
-                            $mapping['class'],
60
-                            $referencedObjectId
61
-                        )
62
-                    );
63
-                }
64
-            }
65
-        }
66
-
67
-        foreach ($config['referenceMany'] as $mapping) {
68
-            $property = $meta->reflClass->getProperty($mapping['field']);
69
-            $property->setAccessible(true);
70
-            if (isset($mapping['mappedBy'])) {
71
-                $id = $ea->extractIdentifier($om, $object);
72
-                $manager = $this->getManager($mapping['type']);
73
-                $class = $mapping['class'];
74
-                $refMeta = $manager->getClassMetadata($class);
75
-                $refConfig = $this->getConfiguration($manager, $refMeta->name);
76
-                if (isset($refConfig['referenceOne'][$mapping['mappedBy']])) {
77
-                    $refMapping = $refConfig['referenceOne'][$mapping['mappedBy']];
78
-                    $identifier = $refMapping['identifier'];
79
-                    $property->setValue(
80
-                        $object,
81
-                        new LazyCollection(
82
-                            function() use ($id, &$manager, $class, $identifier) {
83
-                                $results = $manager
84
-                                    ->getRepository($class)
85
-                                    ->findBy(array(
86
-                                        $identifier => $id,
87
-                                    ));
88
-
89
-                                return new ArrayCollection((is_array($results) ? $results : $results->toArray()));
90
-                            }
91
-                        )
92
-                    );
93
-                }
94
-            }
95
-        }
96
-    }
97
-
98
-    public function prePersist(EventArgs $eventArgs)
99
-    {
100
-        $this->updateReferences($eventArgs);
101
-    }
102
-
103
-    public function preUpdate(EventArgs $eventArgs)
104
-    {
105
-        $this->updateReferences($eventArgs);
106
-    }
107
-
108
-    public function getSubscribedEvents()
109
-    {
110
-        return array(
111
-            'postLoad',
112
-            'loadClassMetadata',
113
-            'prePersist',
114
-            'preUpdate',
115
-        );
116
-    }
117
-
118
-    public function registerManager($type, $manager)
119
-    {
120
-        $this->managers[$type] = $manager;
121
-    }
122
-
123
-    public function getManager($type)
124
-    {
125
-        return $this->managers[$type];
126
-    }
127
-
128
-    protected function getNamespace()
129
-    {
130
-        return __NAMESPACE__;
131
-    }
132
-
133
-    private function updateReferences(EventArgs $eventArgs)
134
-    {
135
-        $ea = $this->getEventAdapter($eventArgs);
136
-        $om = $ea->getObjectManager();
137
-        $object = $ea->getObject();
138
-        $meta = $om->getClassMetadata(get_class($object));
139
-        $config = $this->getConfiguration($om, $meta->name);
140
-        foreach ($config['referenceOne'] as $mapping) {
141
-            if (isset($mapping['identifier'])) {
142
-                $property = $meta->reflClass->getProperty($mapping['field']);
143
-                $property->setAccessible(true);
144
-                $referencedObject = $property->getValue($object);
145
-                if (is_object($referencedObject)) {
146
-                    $meta->setFieldValue(
147
-                        $object,
148
-                        $mapping['identifier'],
149
-                        $ea->getIdentifier(
150
-                            $this->getManager($mapping['type']),
151
-                            $referencedObject
152
-                        )
153
-                    );
154
-                }
155
-            }
156
-        }
157
-    }
158
-}

+ 0 - 50
vendor/gedmo/doctrine-extensions/lib/Gedmo/SoftDeleteable/Mapping/Validator.php View File

@@ -1,50 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\SoftDeleteable\Mapping;
4
-
5
-use Gedmo\Exception\InvalidMappingException;
6
-use Doctrine\Common\Persistence\Mapping\ClassMetadata;
7
-
8
-/**
9
- * This class is used to validate mapping information
10
- *
11
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @package Gedmo.SoftDeleteable.Mapping
14
- * @subpackage Validator
15
- * @link http://www.gediminasm.org
16
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
17
- */
18
-
19
-class Validator
20
-{
21
-    /**
22
-     * List of types which are valid for timestamp
23
-     *
24
-     * @var array
25
-     */
26
-    public static $validTypes = array(
27
-        'date',
28
-        'time',
29
-        'datetime',
30
-        'datetimetz',
31
-        'timestamp',
32
-        'zenddate'
33
-    );
34
-
35
-
36
-    public static function validateField(ClassMetadata $meta, $field)
37
-    {
38
-        if ($meta->isMappedSuperclass) {
39
-            return;
40
-        }
41
-
42
-        $fieldMapping = $meta->getFieldMapping($field);
43
-
44
-        if (!in_array($fieldMapping['type'], self::$validTypes)) {
45
-            throw new InvalidMappingException(sprintf('Field "%s" must be of one of the following types: "%s"',
46
-                $fieldMapping['type'],
47
-                implode(', ', self::$validTypes)));
48
-        }
49
-    }
50
-}

+ 0 - 486
vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/SortableListener.php View File

@@ -1,486 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Sortable;
4
-
5
-use Doctrine\Common\EventArgs;
6
-use Gedmo\Mapping\MappedEventSubscriber;
7
-use Gedmo\Sluggable\Mapping\Event\SortableAdapter;
8
-use Doctrine\ORM\Proxy\Proxy;
9
-
10
-/**
11
- * The SortableListener maintains a sort index on your entities
12
- * to enable arbitrary sorting.
13
- *
14
- * This behavior can impact the performance of your application
15
- * since it does some additional calculations on persisted objects.
16
- *
17
- * @author Lukas Botsch <lukas.botsch@gmail.com>
18
- * @subpackage SortableListener
19
- * @package Gedmo.Sortable
20
- * @link http://www.gediminasm.org
21
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
22
- */
23
-class SortableListener extends MappedEventSubscriber
24
-{
25
-    private $relocations = array();
26
-    private $maxPositions = array();
27
-
28
-    /**
29
-     * Specifies the list of events to listen
30
-     *
31
-     * @return array
32
-     */
33
-    public function getSubscribedEvents()
34
-    {
35
-        return array(
36
-            'onFlush',
37
-            'loadClassMetadata',
38
-            'prePersist',
39
-        );
40
-    }
41
-
42
-    /**
43
-     * Maps additional metadata
44
-     *
45
-     * @param EventArgs $args
46
-     */
47
-    public function loadClassMetadata(EventArgs $args)
48
-    {
49
-        $ea = $this->getEventAdapter($args);
50
-        $this->loadMetadataForObjectClass($ea->getObjectManager(), $args->getClassMetadata());
51
-    }
52
-
53
-    /**
54
-     * Update position on objects being updated during flush
55
-     * if they require changing
56
-     *
57
-     * @param EventArgs $args
58
-     */
59
-    public function onFlush(EventArgs $args)
60
-    {
61
-        $ea = $this->getEventAdapter($args);
62
-        $om = $ea->getObjectManager();
63
-        $uow = $om->getUnitOfWork();
64
-
65
-        // process all objects being deleted
66
-        foreach ($ea->getScheduledObjectDeletions($uow) as $object) {
67
-            $meta = $om->getClassMetadata(get_class($object));
68
-            if ($config = $this->getConfiguration($om, $meta->name)) {
69
-                $this->processDeletion($om, $config, $meta, $object);
70
-            }
71
-        }
72
-
73
-        // process all objects being updated
74
-        foreach ($ea->getScheduledObjectUpdates($uow) as $object) {
75
-            $meta = $om->getClassMetadata(get_class($object));
76
-            if ($config = $this->getConfiguration($om, $meta->name)) {
77
-                $this->processUpdate($om, $config, $meta, $object);
78
-            }
79
-        }
80
-
81
-        // process all objects being inserted
82
-        foreach ($ea->getScheduledObjectInsertions($uow) as $object) {
83
-            $meta = $om->getClassMetadata(get_class($object));
84
-            if ($config = $this->getConfiguration($om, $meta->name)) {
85
-                $this->processInsert($om, $config, $meta, $object);
86
-            }
87
-        }
88
-
89
-        $this->processRelocations($om);
90
-    }
91
-
92
-    /**
93
-     * Update maxPositions as needed
94
-     *
95
-     * @param EventArgs $args
96
-     */
97
-    public function prePersist(EventArgs $args)
98
-    {
99
-        $ea = $this->getEventAdapter($args);
100
-        $om = $ea->getObjectManager();
101
-        $uow = $om->getUnitOfWork();
102
-        $object = $ea->getObject();
103
-        $meta = $om->getClassMetadata(get_class($object));
104
-
105
-        if ($config = $this->getConfiguration($om, $meta->name)) {
106
-            // Get groups
107
-            $groups = $this->getGroups($meta, $config, $object);
108
-
109
-            // Get hash
110
-            $hash = $this->getHash($meta, $groups, $object, $config);
111
-
112
-            // Get max position
113
-            if (!isset($this->maxPositions[$hash])) {
114
-                $this->maxPositions[$hash] = $this->getMaxPosition($om, $meta, $config, $object);
115
-            }
116
-        }
117
-    }
118
-
119
-    /**
120
-     * Computes node positions and updates the sort field in memory and in the db
121
-     * @param object $em ObjectManager
122
-     */
123
-    private function processInsert($em, $config, $meta, $object)
124
-    {
125
-        $uow = $em->getUnitOfWork();
126
-        
127
-        $old = $meta->getReflectionProperty($config['position'])->getValue($object);
128
-        $newPosition = $meta->getReflectionProperty($config['position'])->getValue($object);
129
-        
130
-        if (is_null($newPosition)) {
131
-            $newPosition = -1;
132
-        }
133
-
134
-        // Get groups
135
-        $groups = $this->getGroups($meta, $config, $object);
136
-
137
-        // Get hash
138
-        $hash = $this->getHash($meta, $groups, $object, $config);
139
-
140
-        // Get max position
141
-        if (!isset($this->maxPositions[$hash])) {
142
-            $this->maxPositions[$hash] = $this->getMaxPosition($em, $meta, $config, $object);
143
-        }
144
-
145
-        // Compute position if it is negative
146
-        if ($newPosition < 0) {
147
-            $newPosition += $this->maxPositions[$hash] + 2; // position == -1 => append at end of list
148
-            if ($newPosition < 0) $newPosition = 0;
149
-        }
150
-
151
-        // Set position to max position if it is too big
152
-        $newPosition = min(array($this->maxPositions[$hash] + 1, $newPosition));
153
-
154
-        // Compute relocations
155
-        $relocation = array($hash, $config['useObjectClass'], $groups, $newPosition, -1, +1);
156
-
157
-        // Apply existing relocations
158
-        $applyDelta = 0;
159
-        if (isset($this->relocations[$hash])) {
160
-            foreach ($this->relocations[$hash]['deltas'] as $delta) {
161
-                if ($delta['start'] <= $newPosition
162
-                        && ($delta['stop'] > $newPosition || $delta['stop'] < 0)) {
163
-                    $applyDelta += $delta['delta'];
164
-                }
165
-            }
166
-        }
167
-        $newPosition += $applyDelta;
168
-
169
-        // Add relocations
170
-        call_user_func_array(array($this, 'addRelocation'), $relocation);
171
-
172
-        // Set new position
173
-        if ($old < 0 || is_null($old)) {
174
-            $meta->getReflectionProperty($config['position'])->setValue($object, $newPosition);
175
-            $uow->recomputeSingleEntityChangeSet($meta, $object);
176
-        }
177
-    }
178
-
179
-    /**
180
-     * Computes node positions and updates the sort field in memory and in the db
181
-     * @param object $em ObjectManager
182
-     */
183
-    private function processUpdate($em, $config, $meta, $object)
184
-    {
185
-        $uow = $em->getUnitOfWork();
186
-
187
-        $changed = false;
188
-        $changeSet = $uow->getEntityChangeSet($object);
189
-
190
-        // Get groups
191
-        $groups = $this->getGroups($meta, $config, $object);
192
-        foreach (array_keys($groups) as $group) {
193
-            $changed = $changed || array_key_exists($group, $changeSet);
194
-        }
195
-
196
-        if (array_key_exists($config['position'], $changeSet)) {
197
-            // position was manually updated
198
-            $oldPosition = $changeSet[$config['position']][0];
199
-            $newPosition = $changeSet[$config['position']][1];
200
-            $changed = $changed || $oldPosition != $newPosition;
201
-        } elseif ($changed) {
202
-            // group has changed, so position has to be recalculated
203
-            $oldPosition = -1;
204
-            $newPosition = -1;
205
-            // specific case
206
-        }
207
-        if (!$changed) return;
208
-
209
-        // Get hash
210
-        $hash = $this->getHash($meta, $groups, $object, $config);
211
-
212
-        // Get max position
213
-        if (!isset($this->maxPositions[$hash])) {
214
-            $this->maxPositions[$hash] = $this->getMaxPosition($em, $meta, $config, $object);
215
-        }
216
-
217
-        // Compute position if it is negative
218
-        if ($newPosition < 0) {
219
-            $newPosition += $this->maxPositions[$hash] + 2; // position == -1 => append at end of list
220
-            if ($newPosition < 0) $newPosition = 0;
221
-        }
222
-
223
-        // Set position to max position if it is too big
224
-        $newPosition = min(array($this->maxPositions[$hash] + 1, $newPosition));
225
-        // Compute relocations
226
-        /*
227
-        CASE 1: shift backwards
228
-        |----0----|----1----|----2----|----3----|----4----|
229
-        |--node1--|--node2--|--node3--|--node4--|--node5--|
230
-        Update node4: setPosition(1)
231
-        --> Update position + 1 where position in [1,3)
232
-        |--node1--|--node4--|--node2--|--node3--|--node5--|
233
-        CASE 2: shift forward
234
-        |----0----|----1----|----2----|----3----|----4----|
235
-        |--node1--|--node2--|--node3--|--node4--|--node5--|
236
-        Update node2: setPosition(3)
237
-        --> Update position - 1 where position in (1,3]
238
-        |--node1--|--node3--|--node4--|--node2--|--node5--|
239
-        */
240
-        $relocation = null;
241
-        if ($oldPosition === -1) {
242
-            // special case when group changes
243
-            $relocation = array($hash, $config['useObjectClass'], $groups, $newPosition, -1, +1);
244
-        } elseif ($newPosition < $oldPosition) {
245
-            $relocation = array($hash, $config['useObjectClass'], $groups, $newPosition, $oldPosition, +1);
246
-        } elseif ($newPosition > $oldPosition) {
247
-            $relocation = array($hash, $config['useObjectClass'], $groups, $oldPosition + 1, $newPosition + 1, -1);
248
-        }
249
-
250
-        // Apply existing relocations
251
-        $applyDelta = 0;
252
-        if (isset($this->relocations[$hash])) {
253
-            foreach ($this->relocations[$hash]['deltas'] as $delta) {
254
-                if ($delta['start'] <= $newPosition
255
-                        && ($delta['stop'] > $newPosition || $delta['stop'] < 0)) {
256
-                    $applyDelta += $delta['delta'];
257
-                }
258
-            }
259
-        }
260
-        $newPosition += $applyDelta;
261
-
262
-        // Add relocation
263
-        call_user_func_array(array($this, 'addRelocation'), $relocation);
264
-
265
-        // Set new position
266
-        $meta->getReflectionProperty($config['position'])->setValue($object, $newPosition);
267
-        $uow->recomputeSingleEntityChangeSet($meta, $object);
268
-    }
269
-
270
-    /**
271
-     * Computes node positions and updates the sort field in memory and in the db
272
-     * @param object $em ObjectManager
273
-     */
274
-    private function processDeletion($em, $config, $meta, $object)
275
-    {
276
-        $position = $meta->getReflectionProperty($config['position'])->getValue($object);
277
-
278
-        // Get groups
279
-        $groups = $this->getGroups($meta, $config, $object);
280
-
281
-        // Get hash
282
-        $hash = $this->getHash($meta, $groups, $object, $config);
283
-
284
-        // Get max position
285
-        if (!isset($this->maxPositions[$hash])) {
286
-            $this->maxPositions[$hash] = $this->getMaxPosition($em, $meta, $config, $object);
287
-        }
288
-
289
-        // Add relocation
290
-        $this->addRelocation($hash, $config['useObjectClass'], $groups, $position, -1, -1);
291
-    }
292
-
293
-    private function processRelocations($em)
294
-    {
295
-        foreach ($this->relocations as $hash => $relocation) {
296
-            $config = $this->getConfiguration($em, $relocation['name']);
297
-            foreach ($relocation['deltas'] as $delta) {
298
-                if ($delta['start'] > $this->maxPositions[$hash] || $delta['delta'] == 0) {
299
-                    continue;
300
-                }
301
-                $sign = $delta['delta'] < 0 ? "-" : "+";
302
-                $absDelta = abs($delta['delta']);
303
-                $dql = "UPDATE {$relocation['name']} n";
304
-                $dql .= " SET n.{$config['position']} = n.{$config['position']} {$sign} {$absDelta}";
305
-                $dql .= " WHERE n.{$config['position']} >= {$delta['start']}";
306
-                // if not null, false or 0
307
-                if ($delta['stop'] > 0) {
308
-                    $dql .= " AND n.{$config['position']} < {$delta['stop']}";
309
-                }
310
-                $i = -1;
311
-                $params = array();
312
-                foreach ($relocation['groups'] as $group => $value) {
313
-                    if (is_null($value)) {
314
-                        $dql .= " AND n.{$group} IS NULL";
315
-                    } else {
316
-                        $dql .= " AND n.{$group} = :val___".(++$i);
317
-                        $params['val___'.$i] = $value;
318
-                    }
319
-                }
320
-                $q = $em->createQuery($dql);
321
-                $q->setParameters($params);
322
-                $q->getSingleScalarResult();
323
-                $meta = $em->getClassMetadata($relocation['name']);
324
-
325
-                // now walk through the unit of work in memory objects and sync those
326
-                foreach ($em->getUnitOfWork()->getIdentityMap() as $className => $objects) {
327
-                    // for inheritance mapped classes, only root is always in the identity map
328
-                    if ($className !== $meta->rootEntityName || !$this->getConfiguration($em, $className)) {
329
-                        continue;
330
-                    }
331
-                    foreach ($objects as $object) {
332
-                        if ($object instanceof Proxy && !$object->__isInitialized__) {
333
-                            continue;
334
-                        }
335
-                        $oid = spl_object_hash($object);
336
-                        $pos = $meta->getReflectionProperty($config['position'])->getValue($object);
337
-                        $matches = $pos >= $delta['start'];
338
-                        $matches = $matches && ($delta['stop'] <= 0 || $pos < $delta['stop']);
339
-                        $value = reset($relocation['groups']);
340
-                        while ($matches && ($group = key($relocation['groups']))) {
341
-                            $gr = $meta->getReflectionProperty($group)->getValue($object);
342
-                            if (null === $value) {
343
-                                $matches = $gr === null;
344
-                            } else {
345
-                                $matches = $gr === $value;
346
-                            }
347
-                            $value = next($relocation['groups']);
348
-                        }
349
-                        if ($matches) {
350
-                            $meta->getReflectionProperty($config['position'])->setValue($object, $pos + $delta['delta']);
351
-                            $em->getUnitOfWork()->setOriginalEntityProperty($oid, $config['position'], $pos + $delta['delta']);
352
-                        }
353
-                    }
354
-                }
355
-            }
356
-        }
357
-
358
-        // Clear relocations
359
-        $this->relocations = array();
360
-        $this->maxPositions = array();
361
-    }
362
-
363
-    private function getHash($meta, $groups, $object, &$config)
364
-    {
365
-        $data = $config['useObjectClass'];
366
-        foreach ($groups as $group => $val) {
367
-            if($val instanceof \DateTime) {
368
-                $val = $val->format('c');
369
-            } elseif (is_object($val)) {
370
-                $val = spl_object_hash($val);
371
-            }
372
-            $data .= $group.$val;
373
-        }
374
-        return md5($data);
375
-    }
376
-
377
-    private function getMaxPosition($em, $meta, $config, $object)
378
-    {
379
-        $uow = $em->getUnitOfWork();
380
-        $maxPos = null;
381
-
382
-        // Get groups
383
-        $groups = $this->getGroups($meta, $config, $object);
384
-
385
-        // Get hash
386
-        $hash = $this->getHash($meta, $groups, $object, $config);
387
-
388
-        // Check for cached max position
389
-        if (isset($this->maxPositions[$hash])) {
390
-            return $this->maxPositions[$hash];
391
-        }
392
-
393
-        // Check for groups that are associations. If the value is an object and is
394
-        // scheduled for insert, it has no identifier yet and is obviously new
395
-        // see issue #226
396
-        foreach ($groups as $group => $val) {
397
-            if (is_object($val) && $uow->isScheduledForInsert($val)) {
398
-                return -1;
399
-            }
400
-        }
401
-
402
-        $groups = isset($config["groups"]) ? $config["groups"] : array();
403
-        $qb = $em->createQueryBuilder();
404
-        $qb->select('MAX(n.'.$config['position'].')')
405
-           ->from($config['useObjectClass'], 'n');
406
-        $qb = $this->addGroupWhere($qb, $groups, $meta, $object);
407
-        $query = $qb->getQuery();
408
-        $query->useQueryCache(false);
409
-        $query->useResultCache(false);
410
-        $res = $query->getResult();
411
-        $maxPos = $res[0][1];
412
-        if (is_null($maxPos)) $maxPos = -1;
413
-        return intval($maxPos);
414
-    }
415
-
416
-    private function addGroupWhere($qb, $groups, $meta, $object)
417
-    {
418
-        $i = 1;
419
-        foreach ($groups as $group) {
420
-            $value = $meta->getReflectionProperty($group)->getValue($object);
421
-            $whereFunc = is_null($qb->getDQLPart('where')) ? 'where' : 'andWhere';
422
-            if (is_null($value)) {
423
-                $qb->{$whereFunc}($qb->expr()->isNull('n.'.$group));
424
-            } else {
425
-                $qb->{$whereFunc}('n.'.$group.' = :group__'.$i);
426
-                $qb->setParameter('group__'.$i, $value);
427
-            }
428
-            $i++;
429
-        }
430
-        return $qb;
431
-    }
432
-
433
-    /**
434
-     * Add a relocation rule
435
-     * @param string $hash The hash of the sorting group
436
-     * @param $meta The objects meta data
437
-     * @param array $groups The sorting groups
438
-     * @param int $start Inclusive index to start relocation from
439
-     * @param int $stop Exclusive index to stop relocation at
440
-     * @param int $delta The delta to add to relocated nodes
441
-     */
442
-    private function addRelocation($hash, $class, $groups, $start, $stop, $delta)
443
-    {
444
-        if (!array_key_exists($hash, $this->relocations)) {
445
-            $this->relocations[$hash] = array('name' => $class, 'groups' => $groups, 'deltas' => array());
446
-        }
447
-
448
-        try {
449
-            $newDelta = array('start' => $start, 'stop' => $stop, 'delta' => $delta);
450
-            array_walk($this->relocations[$hash]['deltas'], function(&$val, $idx, $needle) {
451
-                if ($val['start'] == $needle['start'] && $val['stop'] == $needle['stop']) {
452
-                    $val['delta'] += $needle['delta'];
453
-                    throw new \Exception("Found delta. No need to add it again.");
454
-                }
455
-            }, $newDelta);
456
-            $this->relocations[$hash]['deltas'][] = $newDelta;
457
-        } catch (\Exception $e) {}
458
-    }
459
-
460
-    /**
461
-     * @param $meta
462
-     * @param $config
463
-     * @param $object
464
-     *
465
-     * @return array
466
-     */
467
-    private function getGroups($meta, $config, $object)
468
-    {
469
-        $groups = array();
470
-        if (isset($config['groups'])) {
471
-            foreach ($config['groups'] as $group) {
472
-                $groups[$group] = $meta->getReflectionProperty($group)->getValue($object);
473
-            }
474
-        }
475
-
476
-        return $groups;
477
-    }
478
-
479
-    /**
480
-     * {@inheritDoc}
481
-     */
482
-    protected function getNamespace()
483
-    {
484
-        return __NAMESPACE__;
485
-    }
486
-}

+ 0 - 83
vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Annotation.php View File

@@ -1,83 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Timestampable\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\AbstractAnnotationDriver,
6
-    Doctrine\Common\Annotations\AnnotationReader,
7
-    Gedmo\Exception\InvalidMappingException;
8
-
9
-/**
10
- * This is an annotation mapping driver for Timestampable
11
- * behavioral extension. Used for extraction of extended
12
- * metadata from Annotations specificaly for Timestampable
13
- * extension.
14
- *
15
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
16
- * @package Gedmo.Timestampable.Mapping.Driver
17
- * @subpackage Annotation
18
- * @link http://www.gediminasm.org
19
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
20
- */
21
-class Annotation extends AbstractAnnotationDriver
22
-{
23
-    /**
24
-     * Annotation field is timestampable
25
-     */
26
-    const TIMESTAMPABLE = 'Gedmo\\Mapping\\Annotation\\Timestampable';
27
-
28
-    /**
29
-     * List of types which are valid for timestamp
30
-     *
31
-     * @var array
32
-     */
33
-    protected $validTypes = array(
34
-        'date',
35
-        'time',
36
-        'datetime',
37
-        'datetimetz',
38
-        'timestamp',
39
-        'zenddate',
40
-        'vardatetime',
41
-        'integer'
42
-    );
43
-
44
-    /**
45
-     * {@inheritDoc}
46
-     */
47
-    public function readExtendedMetadata($meta, array &$config) {
48
-        $class = $this->getMetaReflectionClass($meta);
49
-        // property annotations
50
-        foreach ($class->getProperties() as $property) {
51
-            if ($meta->isMappedSuperclass && !$property->isPrivate() ||
52
-                $meta->isInheritedField($property->name) ||
53
-                isset($meta->associationMappings[$property->name]['inherited'])
54
-            ) {
55
-                continue;
56
-            }
57
-            if ($timestampable = $this->reader->getPropertyAnnotation($property, self::TIMESTAMPABLE)) {
58
-                $field = $property->getName();
59
-                if (!$meta->hasField($field)) {
60
-                    throw new InvalidMappingException("Unable to find timestampable [{$field}] as mapped property in entity - {$meta->name}");
61
-                }
62
-                if (!$this->isValidField($meta, $field)) {
63
-                    throw new InvalidMappingException("Field - [{$field}] type is not valid and must be 'date', 'datetime' or 'time' in class - {$meta->name}");
64
-                }
65
-                if (!in_array($timestampable->on, array('update', 'create', 'change'))) {
66
-                    throw new InvalidMappingException("Field - [{$field}] trigger 'on' is not one of [update, create, change] in class - {$meta->name}");
67
-                }
68
-                if ($timestampable->on == 'change') {
69
-                    if (!isset($timestampable->field)) {
70
-                        throw new InvalidMappingException("Missing parameters on property - {$field}, field must be set on [change] trigger in class - {$meta->name}");
71
-                    }
72
-                    $field = array(
73
-                        'field' => $field,
74
-                        'trackedField' => $timestampable->field,
75
-                        'value' => $timestampable->value,
76
-                    );
77
-                }
78
-                // properties are unique and mapper checks that, no risk here
79
-                $config[$timestampable->on][] = $field;
80
-            }
81
-        }
82
-    }
83
-}

+ 0 - 99
vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Xml.php View File

@@ -1,99 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Timestampable\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\Xml as BaseXml,
6
-    Gedmo\Exception\InvalidMappingException;
7
-
8
-/**
9
- * This is a xml mapping driver for Timestampable
10
- * behavioral extension. Used for extraction of extended
11
- * metadata from xml specificaly for Timestampable
12
- * extension.
13
- *
14
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
15
- * @author Miha Vrhovnik <miha.vrhovnik@gmail.com>
16
- * @package Gedmo.Timestampable.Mapping.Driver
17
- * @subpackage Xml
18
- * @link http://www.gediminasm.org
19
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
20
- */
21
-class Xml extends BaseXml
22
-{
23
-
24
-    /**
25
-     * List of types which are valid for timestamp
26
-     *
27
-     * @var array
28
-     */
29
-    private $validTypes = array(
30
-        'date',
31
-        'time',
32
-        'datetime',
33
-        'datetimetz',
34
-        'timestamp',
35
-        'zenddate',
36
-        'vardatetime',
37
-        'integer'
38
-    );
39
-
40
-    /**
41
-     * {@inheritDoc}
42
-     */
43
-    public function readExtendedMetadata($meta, array &$config)
44
-    {
45
-        /**
46
-         * @var \SimpleXmlElement $mapping
47
-         */
48
-        $mapping = $this->_getMapping($meta->name);
49
-
50
-        if (isset($mapping->field)) {
51
-            /**
52
-             * @var \SimpleXmlElement $fieldMapping
53
-             */
54
-            foreach ($mapping->field as $fieldMapping) {
55
-                $fieldMappingDoctrine = $fieldMapping;
56
-                $fieldMapping = $fieldMapping->children(self::GEDMO_NAMESPACE_URI);
57
-                if (isset($fieldMapping->timestampable)) {
58
-                    /**
59
-                     * @var \SimpleXmlElement $data
60
-                     */
61
-                    $data = $fieldMapping->timestampable;
62
-
63
-                    $field = $this->_getAttribute($fieldMappingDoctrine, 'name');
64
-                    if (!$this->isValidField($meta, $field)) {
65
-                        throw new InvalidMappingException("Field - [{$field}] type is not valid and must be 'date', 'datetime' or 'time' in class - {$meta->name}");
66
-                    }
67
-                    if (!$this->_isAttributeSet($data, 'on') || !in_array($this->_getAttribute($data, 'on'), array('update', 'create', 'change'))) {
68
-                        throw new InvalidMappingException("Field - [{$field}] trigger 'on' is not one of [update, create, change] in class - {$meta->name}");
69
-                    }
70
-
71
-                    if ($this->_getAttribute($data, 'on') == 'change') {
72
-                        if (!$this->_isAttributeSet($data, 'field')) {
73
-                            throw new InvalidMappingException("Missing parameters on property - {$field}, field must be set on [change] trigger in class - {$meta->name}");
74
-                        }
75
-                        $field = array(
76
-                            'field' => $field,
77
-                            'trackedField' => $this->_getAttribute($data, 'field'),
78
-                            'value' => $this->_isAttributeSet($data, 'value') ? $this->_getAttribute($data, 'value') : null,
79
-                        );
80
-                    }
81
-                    $config[$this->_getAttribute($data, 'on')][] = $field;
82
-                }
83
-            }
84
-        }
85
-    }
86
-
87
-    /**
88
-     * Checks if $field type is valid
89
-     *
90
-     * @param object $meta
91
-     * @param string $field
92
-     * @return boolean
93
-     */
94
-    protected function isValidField($meta, $field)
95
-    {
96
-        $mapping = $meta->getFieldMapping($field);
97
-        return $mapping && in_array($mapping['type'], $this->validTypes);
98
-    }
99
-}

+ 0 - 99
vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/Mapping/Driver/Yaml.php View File

@@ -1,99 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Timestampable\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\File,
6
-    Gedmo\Mapping\Driver,
7
-    Gedmo\Exception\InvalidMappingException;
8
-
9
-/**
10
- * This is a yaml mapping driver for Timestampable
11
- * behavioral extension. Used for extraction of extended
12
- * metadata from yaml specificaly for Timestampable
13
- * extension.
14
- *
15
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
16
- * @package Gedmo.Timestampable.Mapping.Driver
17
- * @subpackage Yaml
18
- * @link http://www.gediminasm.org
19
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
20
- */
21
-class Yaml extends File implements Driver
22
-{
23
-    /**
24
-     * File extension
25
-     * @var string
26
-     */
27
-    protected $_extension = '.dcm.yml';
28
-
29
-    /**
30
-     * List of types which are valid for timestamp
31
-     *
32
-     * @var array
33
-     */
34
-    private $validTypes = array(
35
-        'date',
36
-        'time',
37
-        'datetime',
38
-        'datetimetz',
39
-        'timestamp',
40
-        'zenddate',
41
-        'vardatetime',
42
-        'integer'
43
-    );
44
-
45
-    /**
46
-     * {@inheritDoc}
47
-     */
48
-    public function readExtendedMetadata($meta, array &$config)
49
-    {
50
-        $mapping = $this->_getMapping($meta->name);
51
-
52
-        if (isset($mapping['fields'])) {
53
-            foreach ($mapping['fields'] as $field => $fieldMapping) {
54
-                if (isset($fieldMapping['gedmo']['timestampable'])) {
55
-                    $mappingProperty = $fieldMapping['gedmo']['timestampable'];
56
-                    if (!$this->isValidField($meta, $field)) {
57
-                        throw new InvalidMappingException("Field - [{$field}] type is not valid and must be 'date', 'datetime' or 'time' in class - {$meta->name}");
58
-                    }
59
-                    if (!isset($mappingProperty['on']) || !in_array($mappingProperty['on'], array('update', 'create', 'change'))) {
60
-                        throw new InvalidMappingException("Field - [{$field}] trigger 'on' is not one of [update, create, change] in class - {$meta->name}");
61
-                    }
62
-
63
-                    if ($mappingProperty['on'] == 'change') {
64
-                        if (!isset($mappingProperty['field'])) {
65
-                            throw new InvalidMappingException("Missing parameters on property - {$field}, field must be set on [change] trigger in class - {$meta->name}");
66
-                        }
67
-                        $field = array(
68
-                            'field' => $field,
69
-                            'trackedField' => $mappingProperty['field'],
70
-                            'value' => isset($mappingProperty['value']) ? $mappingProperty['value'] : null,
71
-                        );
72
-                    }
73
-                    $config[$mappingProperty['on']][] = $field;
74
-                }
75
-            }
76
-        }
77
-    }
78
-
79
-    /**
80
-     * {@inheritDoc}
81
-     */
82
-    protected function _loadMappingFile($file)
83
-    {
84
-        return \Symfony\Component\Yaml\Yaml::parse($file);
85
-    }
86
-
87
-    /**
88
-     * Checks if $field type is valid
89
-     *
90
-     * @param object $meta
91
-     * @param string $field
92
-     * @return boolean
93
-     */
94
-    protected function isValidField($meta, $field)
95
-    {
96
-        $mapping = $meta->getFieldMapping($field);
97
-        return $mapping && in_array($mapping['type'], $this->validTypes);
98
-    }
99
-}

+ 0 - 131
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tool/Wrapper/EntityWrapper.php View File

@@ -1,131 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tool\Wrapper;
4
-
5
-use Doctrine\ORM\EntityManager;
6
-use Doctrine\ORM\Proxy\Proxy;
7
-
8
-/**
9
- * Wraps entity or proxy for more convenient
10
- * manipulation
11
- *
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @package Gedmo.Tool.Wrapper
14
- * @subpackage EntityWrapper
15
- * @link http://www.gediminasm.org
16
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
17
- */
18
-class EntityWrapper extends AbstractWrapper
19
-{
20
-    /**
21
-     * Entity identifier
22
-     *
23
-     * @var array
24
-     */
25
-    private $identifier;
26
-
27
-    /**
28
-     * True if entity or proxy is loaded
29
-     *
30
-     * @var boolean
31
-     */
32
-    private $initialized = false;
33
-
34
-    /**
35
-     * Wrapp entity
36
-     *
37
-     * @param object $entity
38
-     * @param \Doctrine\ORM\EntityManager $em
39
-     */
40
-    public function __construct($entity, EntityManager $em)
41
-    {
42
-        $this->om = $em;
43
-        $this->object = $entity;
44
-        $this->meta = $em->getClassMetadata(get_class($this->object));
45
-    }
46
-
47
-    /**
48
-     * {@inheritDoc}
49
-     */
50
-    public function getPropertyValue($property)
51
-    {
52
-        $this->initialize();
53
-        return $this->meta->getReflectionProperty($property)->getValue($this->object);
54
-    }
55
-
56
-    /**
57
-     * {@inheritDoc}
58
-     */
59
-    public function setPropertyValue($property, $value)
60
-    {
61
-        $this->initialize();
62
-        $this->meta->getReflectionProperty($property)->setValue($this->object, $value);
63
-        return $this;
64
-    }
65
-
66
-    /**
67
-     * {@inheritDoc}
68
-     */
69
-    public function hasValidIdentifier()
70
-    {
71
-        return (null !== $this->getIdentifier());
72
-    }
73
-
74
-    /**
75
-     * {@inheritDoc}
76
-     */
77
-    public function getRootObjectName()
78
-    {
79
-        return $this->meta->rootEntityName;
80
-    }
81
-
82
-    /**
83
-     * {@inheritDoc}
84
-     */
85
-    public function getIdentifier($single = true)
86
-    {
87
-        if (null === $this->identifier) {
88
-            if ($this->object instanceof Proxy) {
89
-                $uow = $this->om->getUnitOfWork();
90
-                if ($uow->isInIdentityMap($this->object)) {
91
-                    $this->identifier = $uow->getEntityIdentifier($this->object);
92
-                } else {
93
-                    $this->initialize();
94
-                }
95
-            }
96
-            if (null === $this->identifier) {
97
-                $this->identifier = array();
98
-                $incomplete = false;
99
-                foreach ($this->meta->identifier as $name) {
100
-                    $this->identifier[$name] = $this->getPropertyValue($name);
101
-                    if (null === $this->identifier[$name]) {
102
-                        $incomplete = true;
103
-                    }
104
-                }
105
-                if ($incomplete) {
106
-                    $this->identifier = null;
107
-                }
108
-            }
109
-        }
110
-        if ($single && is_array($this->identifier)) {
111
-            return reset($this->identifier);
112
-        }
113
-        return $this->identifier;
114
-    }
115
-
116
-    /**
117
-     * Initialize the entity if it is proxy
118
-     * required when is detached or not initialized
119
-     */
120
-    protected function initialize()
121
-    {
122
-        if (!$this->initialized) {
123
-            if ($this->object instanceof Proxy) {
124
-                $uow = $this->om->getUnitOfWork();
125
-                if (!$this->object->__isInitialized__) {
126
-                    $this->object->__load();
127
-                }
128
-            }
129
-        }
130
-    }
131
-}

+ 0 - 745
vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/TranslatableListener.php View File

@@ -1,745 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Translatable;
4
-
5
-use Doctrine\Common\EventArgs;
6
-use Doctrine\ORM\ORMInvalidArgumentException;
7
-use Gedmo\Tool\Wrapper\AbstractWrapper;
8
-use Gedmo\Mapping\MappedEventSubscriber;
9
-use Gedmo\Translatable\Mapping\Event\TranslatableAdapter;
10
-use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation;
11
-use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;
12
-
13
-/**
14
- * The translation listener handles the generation and
15
- * loading of translations for entities which implements
16
- * the Translatable interface.
17
- *
18
- * This behavior can impact the performance of your application
19
- * since it does an additional query for each field to translate.
20
- *
21
- * Nevertheless the annotation metadata is properly cached and
22
- * it is not a big overhead to lookup all entity annotations since
23
- * the caching is activated for metadata
24
- *
25
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
26
- * @package Gedmo.Translatable
27
- * @subpackage TranslatableListener
28
- * @link http://www.gediminasm.org
29
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
30
- */
31
-class TranslatableListener extends MappedEventSubscriber
32
-{
33
-    /**
34
-     * Query hint to override the fallback of translations
35
-     * integer 1 for true, 0 false
36
-     */
37
-    const HINT_FALLBACK = 'gedmo.translatable.fallback';
38
-
39
-    /**
40
-     * Query hint to override the fallback locale
41
-     */
42
-    const HINT_TRANSLATABLE_LOCALE = 'gedmo.translatable.locale';
43
-
44
-    /**
45
-     * Query hint to use inner join strategy for translations
46
-     */
47
-    const HINT_INNER_JOIN = 'gedmo.translatable.inner_join.translations';
48
-
49
-    /**
50
-     * Locale which is set on this listener.
51
-     * If Entity being translated has locale defined it
52
-     * will override this one
53
-     *
54
-     * @var string
55
-     */
56
-    protected $locale = 'en_US';
57
-
58
-    /**
59
-     * Default locale, this changes behavior
60
-     * to not update the original record field if locale
61
-     * which is used for updating is not default. This
62
-     * will load the default translation in other locales
63
-     * if record is not translated yet
64
-     *
65
-     * @var string
66
-     */
67
-    private $defaultLocale = 'en_US';
68
-
69
-    /**
70
-     * If this is set to false, when if entity does
71
-     * not have a translation for requested locale
72
-     * it will show a blank value
73
-     *
74
-     * @var boolean
75
-     */
76
-    private $translationFallback = false;
77
-
78
-    /**
79
-     * List of translations which do not have the foreign
80
-     * key generated yet - MySQL case. These translations
81
-     * will be updated with new keys on postPersist event
82
-     *
83
-     * @var array
84
-     */
85
-    private $pendingTranslationInserts = array();
86
-
87
-    /**
88
-     * Currently in case if there is TranslationQueryWalker
89
-     * in charge. We need to skip issuing additional queries
90
-     * on load
91
-     *
92
-     * @var boolean
93
-     */
94
-    private $skipOnLoad = false;
95
-
96
-    /**
97
-     * Tracks locale the objects currently translated in
98
-     *
99
-     * @var array
100
-     */
101
-    private $translatedInLocale = array();
102
-
103
-    /**
104
-     * Whether or not, to persist default locale
105
-     * translation or keep it in original record
106
-     *
107
-     * @var boolean
108
-     */
109
-    private $persistDefaultLocaleTranslation = false;
110
-
111
-    /**
112
-     * Tracks translation object for default locale
113
-     *
114
-     * @var array
115
-     */
116
-    private $translationInDefaultLocale = array();
117
-
118
-    /**
119
-     * Specifies the list of events to listen
120
-     *
121
-     * @return array
122
-     */
123
-    public function getSubscribedEvents()
124
-    {
125
-        return array(
126
-            'postLoad',
127
-            'postPersist',
128
-            'preFlush',
129
-            'onFlush',
130
-            'loadClassMetadata'
131
-        );
132
-    }
133
-
134
-    /**
135
-     * Set to skip or not onLoad event
136
-     *
137
-     * @param boolean $bool
138
-     * @return TranslatableListener
139
-     */
140
-    public function setSkipOnLoad($bool)
141
-    {
142
-        $this->skipOnLoad = (bool)$bool;
143
-        return $this;
144
-    }
145
-
146
-    /**
147
-     * Whether or not, to persist default locale
148
-     * translation or keep it in original record
149
-     *
150
-     * @param boolean $bool
151
-     * @return \Gedmo\Translatable\TranslatableListener
152
-     */
153
-    public function setPersistDefaultLocaleTranslation($bool)
154
-    {
155
-        $this->persistDefaultLocaleTranslation = (bool)$bool;
156
-        return $this;
157
-    }
158
-
159
-    /**
160
-     * Check if should persist default locale
161
-     * translation or keep it in original record
162
-     *
163
-     * @return boolean
164
-     */
165
-    public function getPersistDefaultLocaleTranslation()
166
-    {
167
-        return (bool)$this->persistDefaultLocaleTranslation;
168
-    }
169
-
170
-    /**
171
-     * Add additional $translation for pending $oid object
172
-     * which is being inserted
173
-     *
174
-     * @param string $oid
175
-     * @param object $translation
176
-     */
177
-    public function addPendingTranslationInsert($oid, $translation)
178
-    {
179
-        $this->pendingTranslationInserts[$oid][] = $translation;
180
-    }
181
-
182
-    /**
183
-     * Maps additional metadata
184
-     *
185
-     * @param EventArgs $eventArgs
186
-     * @return void
187
-     */
188
-    public function loadClassMetadata(EventArgs $eventArgs)
189
-    {
190
-        $ea = $this->getEventAdapter($eventArgs);
191
-        $this->loadMetadataForObjectClass($ea->getObjectManager(), $eventArgs->getClassMetadata());
192
-    }
193
-
194
-    /**
195
-     * Get the translation class to be used
196
-     * for the object $class
197
-     *
198
-     * @param TranslatableAdapter $ea
199
-     * @param string $class
200
-     * @return string
201
-     */
202
-    public function getTranslationClass(TranslatableAdapter $ea, $class)
203
-    {
204
-        return isset(self::$configurations[$this->name][$class]['translationClass']) ?
205
-            self::$configurations[$this->name][$class]['translationClass'] :
206
-            $ea->getDefaultTranslationClass()
207
-        ;
208
-    }
209
-
210
-    /**
211
-     * Enable or disable translation fallback
212
-     * to original record value
213
-     *
214
-     * @param boolean $bool
215
-     * @return TranslatableListener
216
-     */
217
-    public function setTranslationFallback($bool)
218
-    {
219
-        $this->translationFallback = (bool)$bool;
220
-        return $this;
221
-    }
222
-
223
-    /**
224
-     * Weather or not is using the translation
225
-     * fallback to original record
226
-     *
227
-     * @return boolean
228
-     */
229
-    public function getTranslationFallback()
230
-    {
231
-        return $this->translationFallback;
232
-    }
233
-
234
-    /**
235
-     * Set the locale to use for translation listener
236
-     *
237
-     * @param string $locale
238
-     * @return TranslatableListener
239
-     */
240
-    public function setTranslatableLocale($locale)
241
-    {
242
-        $this->validateLocale($locale);
243
-        $this->locale = $locale;
244
-        return $this;
245
-    }
246
-
247
-    /**
248
-     * Sets the default locale, this changes behavior
249
-     * to not update the original record field if locale
250
-     * which is used for updating is not default
251
-     *
252
-     * @param string $locale
253
-     * @return TranslatableListener
254
-     */
255
-    public function setDefaultLocale($locale)
256
-    {
257
-        $this->validateLocale($locale);
258
-        $this->defaultLocale = $locale;
259
-        return $this;
260
-    }
261
-
262
-    /**
263
-     * Gets the default locale
264
-     *
265
-     * @return string
266
-     */
267
-    public function getDefaultLocale()
268
-    {
269
-        return $this->defaultLocale;
270
-    }
271
-
272
-    /**
273
-     * Get currently set global locale, used
274
-     * extensively during query execution
275
-     *
276
-     * @return string
277
-     */
278
-    public function getListenerLocale()
279
-    {
280
-        return $this->locale;
281
-    }
282
-
283
-    /**
284
-     * Gets the locale to use for translation. Loads object
285
-     * defined locale first..
286
-     *
287
-     * @param object $object
288
-     * @param object $meta
289
-     * @throws RuntimeException - if language or locale property is not
290
-     *         found in entity
291
-     * @return string
292
-     */
293
-    public function getTranslatableLocale($object, $meta)
294
-    {
295
-        $locale = $this->locale;
296
-        if (isset(self::$configurations[$this->name][$meta->name]['locale'])) {
297
-            $class = $meta->getReflectionClass();
298
-            $reflectionProperty = $class->getProperty(self::$configurations[$this->name][$meta->name]['locale']);
299
-            if (!$reflectionProperty) {
300
-                $column = self::$configurations[$this->name][$meta->name]['locale'];
301
-                throw new \Gedmo\Exception\RuntimeException("There is no locale or language property ({$column}) found on object: {$meta->name}");
302
-            }
303
-            $reflectionProperty->setAccessible(true);
304
-            $value = $reflectionProperty->getValue($object);
305
-            try {
306
-                $this->validateLocale($value);
307
-                $locale = $value;
308
-            } catch(\Gedmo\Exception\InvalidArgumentException $e) {}
309
-        }
310
-
311
-        return $locale;
312
-    }
313
-
314
-    /**
315
-     * Handle translation changes in default locale
316
-     *
317
-     * This has to be done in the preFlush because, when an entity has been loaded
318
-     * in a different locale, no changes will be detected.
319
-     *
320
-     * @param EventArgs $args
321
-     * @return void
322
-     */
323
-    public function preFlush(EventArgs $args)
324
-    {
325
-        $ea = $this->getEventAdapter($args);
326
-        $om = $ea->getObjectManager();
327
-        $uow = $om->getUnitOfWork();
328
-
329
-        foreach ($this->translationInDefaultLocale as $oid => $fields) {
330
-            $trans = reset($fields);
331
-            if ($ea->usesPersonalTranslation(get_class($trans))) {
332
-                $entity = $trans->getObject();
333
-            } else {
334
-                $entity = $uow->tryGetById($trans->getForeignKey(), $trans->getObjectClass());
335
-            }
336
-
337
-            if (!$entity) {
338
-                continue;
339
-            }
340
-
341
-            try {
342
-                $uow->scheduleForUpdate($entity);
343
-            } catch (ORMInvalidArgumentException $e) {
344
-                foreach ($fields as $field => $trans) {
345
-                    $this->removeTranslationInDefaultLocale($oid, $field);
346
-                }
347
-            }
348
-        }
349
-    }
350
-
351
-    /**
352
-     * Looks for translatable objects being inserted or updated
353
-     * for further processing
354
-     *
355
-     * @param EventArgs $args
356
-     * @return void
357
-     */
358
-    public function onFlush(EventArgs $args)
359
-    {
360
-        $ea = $this->getEventAdapter($args);
361
-        $om = $ea->getObjectManager();
362
-        $uow = $om->getUnitOfWork();
363
-        // check all scheduled inserts for Translatable objects
364
-        foreach ($ea->getScheduledObjectInsertions($uow) as $object) {
365
-            $meta = $om->getClassMetadata(get_class($object));
366
-            $config = $this->getConfiguration($om, $meta->name);
367
-            if (isset($config['fields'])) {
368
-                $this->handleTranslatableObjectUpdate($ea, $object, true);
369
-            }
370
-        }
371
-        // check all scheduled updates for Translatable entities
372
-        foreach ($ea->getScheduledObjectUpdates($uow) as $object) {
373
-            $meta = $om->getClassMetadata(get_class($object));
374
-            $config = $this->getConfiguration($om, $meta->name);
375
-            if (isset($config['fields'])) {
376
-                $this->handleTranslatableObjectUpdate($ea, $object, false);
377
-            }
378
-        }
379
-        // check scheduled deletions for Translatable entities
380
-        foreach ($ea->getScheduledObjectDeletions($uow) as $object) {
381
-            $meta = $om->getClassMetadata(get_class($object));
382
-            $config = $this->getConfiguration($om, $meta->name);
383
-            if (isset($config['fields'])) {
384
-                $wrapped = AbstractWrapper::wrap($object, $om);
385
-                $transClass = $this->getTranslationClass($ea, $meta->name);
386
-                $ea->removeAssociatedTranslations($wrapped, $transClass, $config['useObjectClass']);
387
-            }
388
-        }
389
-    }
390
-
391
-     /**
392
-     * Checks for inserted object to update their translation
393
-     * foreign keys
394
-     *
395
-     * @param EventArgs $args
396
-     * @return void
397
-     */
398
-    public function postPersist(EventArgs $args)
399
-    {
400
-        $ea = $this->getEventAdapter($args);
401
-        $om = $ea->getObjectManager();
402
-        $object = $ea->getObject();
403
-        $meta = $om->getClassMetadata(get_class($object));
404
-        // check if entity is tracked by translatable and without foreign key
405
-        if ($this->getConfiguration($om, $meta->name) && count($this->pendingTranslationInserts)) {
406
-            $oid = spl_object_hash($object);
407
-            if (array_key_exists($oid, $this->pendingTranslationInserts)) {
408
-                // load the pending translations without key
409
-                $wrapped = AbstractWrapper::wrap($object, $om);
410
-                $objectId = $wrapped->getIdentifier();
411
-                foreach ($this->pendingTranslationInserts[$oid] as $translation) {
412
-                    $translation->setForeignKey($objectId);
413
-                    $ea->insertTranslationRecord($translation);
414
-                }
415
-                unset($this->pendingTranslationInserts[$oid]);
416
-            }
417
-        }
418
-    }
419
-
420
-    /**
421
-     * After object is loaded, listener updates the translations
422
-     * by currently used locale
423
-     *
424
-     * @param EventArgs $args
425
-     * @return void
426
-     */
427
-    public function postLoad(EventArgs $args)
428
-    {
429
-        $ea = $this->getEventAdapter($args);
430
-        $om = $ea->getObjectManager();
431
-        $object = $ea->getObject();
432
-        $meta = $om->getClassMetadata(get_class($object));
433
-        $config = $this->getConfiguration($om, $meta->name);
434
-        if (isset($config['fields'])) {
435
-            $locale = $this->getTranslatableLocale($object, $meta);
436
-            $oid = spl_object_hash($object);
437
-            $this->translatedInLocale[$oid] = $locale;
438
-        }
439
-
440
-        if ($this->skipOnLoad) {
441
-            return;
442
-        }
443
-
444
-        if (isset($config['fields']) && $locale !== $this->defaultLocale) {
445
-            // fetch translations
446
-            $translationClass = $this->getTranslationClass($ea, $config['useObjectClass']);
447
-            $result = $ea->loadTranslations(
448
-                $object,
449
-                $translationClass,
450
-                $locale,
451
-                $config['useObjectClass']
452
-            );
453
-            // translate object's translatable properties
454
-            foreach ($config['fields'] as $field) {
455
-                $translated = '';
456
-                foreach ((array)$result as $entry) {
457
-                    if ($entry['field'] == $field) {
458
-                        $translated = $entry['content'];
459
-                        break;
460
-                    }
461
-                }
462
-                // update translation
463
-                if ($translated
464
-                    || (!$this->translationFallback && (!isset($config['fallback'][$field]) || !$config['fallback'][$field]))
465
-                    || ($this->translationFallback && isset($config['fallback'][$field]) && !$config['fallback'][$field])
466
-                ) {
467
-                    $ea->setTranslationValue($object, $field, $translated);
468
-                    // ensure clean changeset
469
-                    $ea->setOriginalObjectProperty(
470
-                        $om->getUnitOfWork(),
471
-                        $oid,
472
-                        $field,
473
-                        $meta->getReflectionProperty($field)->getValue($object)
474
-                    );
475
-                }
476
-            }
477
-        }
478
-    }
479
-
480
-    /**
481
-     * {@inheritDoc}
482
-     */
483
-    protected function getNamespace()
484
-    {
485
-        return __NAMESPACE__;
486
-    }
487
-
488
-    /**
489
-     * Validates the given locale
490
-     *
491
-     * @param string $locale - locale to validate
492
-     * @throws InvalidArgumentException if locale is not valid
493
-     * @return void
494
-     */
495
-    protected function validateLocale($locale)
496
-    {
497
-        if (!is_string($locale) || !strlen($locale)) {
498
-            throw new \Gedmo\Exception\InvalidArgumentException('Locale or language cannot be empty and must be set through Listener or Entity');
499
-        }
500
-    }
501
-
502
-    /**
503
-     * Creates the translation for object being flushed
504
-     *
505
-     * @param TranslatableAdapter $ea
506
-     * @param object $object
507
-     * @param boolean $isInsert
508
-     * @throws UnexpectedValueException - if locale is not valid, or
509
-     *      primary key is composite, missing or invalid
510
-     * @return void
511
-     */
512
-    private function handleTranslatableObjectUpdate(TranslatableAdapter $ea, $object, $isInsert)
513
-    {
514
-        $om = $ea->getObjectManager();
515
-        $wrapped = AbstractWrapper::wrap($object, $om);
516
-        $meta = $wrapped->getMetadata();
517
-        $config = $this->getConfiguration($om, $meta->name);
518
-        // no need cache, metadata is loaded only once in MetadataFactoryClass
519
-        $translationClass = $this->getTranslationClass($ea, $config['useObjectClass']);
520
-        $translationMetadata = $om->getClassMetadata($translationClass);
521
-
522
-        // check for the availability of the primary key
523
-        $objectId = $wrapped->getIdentifier();
524
-        // load the currently used locale
525
-        $locale = $this->getTranslatableLocale($object, $meta);
526
-
527
-        $uow = $om->getUnitOfWork();
528
-        $oid = spl_object_hash($object);
529
-        $changeSet = $ea->getObjectChangeSet($uow, $object);
530
-        $translatableFields = $config['fields'];
531
-        foreach ($translatableFields as $field) {
532
-            $wasPersistedSeparetely = false;
533
-            $skip = isset($this->translatedInLocale[$oid]) && $locale === $this->translatedInLocale[$oid];
534
-            $skip = $skip && !isset($changeSet[$field]) && !$this->getTranslationInDefaultLocale($oid, $field);
535
-            if ($skip) {
536
-                continue; // locale is same and nothing changed
537
-            }
538
-            $translation = null;
539
-            foreach ($ea->getScheduledObjectInsertions($uow) as $trans) {
540
-                if ($locale !== $this->defaultLocale
541
-                    && get_class($trans) === $translationClass
542
-                    && $trans->getLocale() === $this->defaultLocale
543
-                    && $trans->getField() === $field
544
-                    && $this->belongsToObject($ea, $trans, $object)) {
545
-                    $this->setTranslationInDefaultLocale($oid, $field, $trans);
546
-                    break;
547
-                }
548
-            }
549
-            // lookup persisted translations
550
-            if ($ea->usesPersonalTranslation($translationClass)) {
551
-                foreach ($ea->getScheduledObjectInsertions($uow) as $trans) {
552
-                    $wasPersistedSeparetely = get_class($trans) === $translationClass
553
-                        && $trans->getLocale() === $locale
554
-                        && $trans->getField() === $field
555
-                        && $trans->getObject() === $object
556
-                    ;
557
-                    if ($wasPersistedSeparetely) {
558
-                        $translation = $trans;
559
-                        break;
560
-                    }
561
-                }
562
-            }
563
-            // check if translation allready is created
564
-            if (!$isInsert && !$translation) {
565
-                $translation = $ea->findTranslation(
566
-                    $wrapped,
567
-                    $locale,
568
-                    $field,
569
-                    $translationClass,
570
-                    $config['useObjectClass']
571
-                );
572
-            }
573
-
574
-            // create new translation if translation not already created and locale is different from default locale, otherwise, we have the date in the original record
575
-            $persistNewTranslation = !$translation
576
-                && ($locale !== $this->defaultLocale || $this->persistDefaultLocaleTranslation)
577
-            ;
578
-            if ($persistNewTranslation) {
579
-                $translation = $translationMetadata->newInstance();
580
-                $translation->setLocale($locale);
581
-                $translation->setField($field);
582
-                if ($ea->usesPersonalTranslation($translationClass)) {
583
-                    $translation->setObject($object);
584
-                } else {
585
-                    $translation->setObjectClass($config['useObjectClass']);
586
-                    $translation->setForeignKey($objectId);
587
-                }
588
-            }
589
-
590
-            if ($translation) {
591
-                // set the translated field, take value using reflection
592
-                $content = $ea->getTranslationValue($object, $field);
593
-                $translation->setContent($content);
594
-                // check if need to update in database
595
-                $transWrapper = AbstractWrapper::wrap($translation, $om);
596
-                if ((is_bool($content) || is_int($content) || (is_string($content) && strlen($content) > 0) || !empty($content)) && ($isInsert || !$transWrapper->getIdentifier() || isset($changeSet[$field]))) {
597
-                    if ($isInsert && !$objectId && !$ea->usesPersonalTranslation($translationClass)) {
598
-                        // if we do not have the primary key yet available
599
-                        // keep this translation in memory to insert it later with foreign key
600
-                        $this->pendingTranslationInserts[spl_object_hash($object)][] = $translation;
601
-                    } else {
602
-                        // persist and compute change set for translation
603
-                        if ($wasPersistedSeparetely) {
604
-                            $ea->recomputeSingleObjectChangeset($uow, $translationMetadata, $translation);
605
-                        } else {
606
-                            $om->persist($translation);
607
-                            $uow->computeChangeSet($translationMetadata, $translation);
608
-                        }
609
-                    }
610
-                }
611
-            }
612
-
613
-            if ($isInsert && $this->getTranslationInDefaultLocale($oid, $field) !== null) {
614
-                // We can't rely on object field value which is created in non-default locale.
615
-                // If we provide translation for default locale as well, the latter is considered to be trusted
616
-                // and object content should be overridden.
617
-                $wrapped->setPropertyValue($field, $this->getTranslationInDefaultLocale($oid, $field)->getContent());
618
-                $ea->recomputeSingleObjectChangeset($uow, $meta, $object);
619
-                $this->removeTranslationInDefaultLocale($oid, $field);
620
-            }
621
-        }
622
-        $this->translatedInLocale[$oid] = $locale;
623
-        // check if we have default translation and need to reset the translation
624
-        if (!$isInsert && strlen($this->defaultLocale)) {
625
-            $this->validateLocale($this->defaultLocale);
626
-            $modifiedChangeSet = $changeSet;
627
-            foreach ($changeSet as $field => $changes) {
628
-                if (in_array($field, $translatableFields)) {
629
-                    if ($locale !== $this->defaultLocale) {
630
-                        $ea->setOriginalObjectProperty($uow, $oid, $field, $changes[0]);
631
-                        unset($modifiedChangeSet[$field]);
632
-                    }
633
-                }
634
-            }
635
-            $ea->recomputeSingleObjectChangeset($uow, $meta, $object);
636
-            // cleanup current changeset only if working in a another locale different than de default one, otherwise the changeset will always be reverted
637
-            if ($locale !== $this->defaultLocale) {
638
-                $ea->clearObjectChangeSet($uow, $oid);
639
-                // recompute changeset only if there are changes other than reverted translations
640
-                if ($modifiedChangeSet || $this->hasTranslationsInDefaultLocale($oid)) {
641
-                    foreach ($modifiedChangeSet as $field => $changes) {
642
-                        $ea->setOriginalObjectProperty($uow, $oid, $field, $changes[0]);
643
-                    }
644
-                    foreach ($translatableFields as $field) {
645
-                        if ($this->getTranslationInDefaultLocale($oid, $field) !== null) {
646
-                            $wrapped->setPropertyValue($field, $this->getTranslationInDefaultLocale($oid, $field)->getContent());
647
-                            $this->removeTranslationInDefaultLocale($oid, $field);
648
-                        }
649
-                    }
650
-                    $ea->recomputeSingleObjectChangeset($uow, $meta, $object);
651
-                }
652
-            }
653
-        }
654
-    }
655
-
656
-    /**
657
-     * Sets translation object which represents translation in default language.
658
-     *
659
-     * @param    string    $oid     hash of basic entity
660
-     * @param    string    $field   field of basic entity
661
-     * @param    mixed     $trans   Translation object
662
-     */
663
-    public function setTranslationInDefaultLocale($oid, $field, $trans)
664
-    {
665
-        if (!isset($this->translationInDefaultLocale[$oid])) {
666
-            $this->translationInDefaultLocale[$oid] = array();
667
-        }
668
-        $this->translationInDefaultLocale[$oid][$field] = $trans;
669
-    }
670
-
671
-    /**
672
-     * Removes translation object which represents translation in default language.
673
-     * This is for internal use only.
674
-     *
675
-     * @param string    $oid     hash of the basic entity
676
-     * @param string    $field   field of basic entity
677
-     */
678
-    private function removeTranslationInDefaultLocale($oid, $field)
679
-    {
680
-        if (isset($this->translationInDefaultLocale[$oid])) {
681
-            if (isset($this->translationInDefaultLocale[$oid][$field])) {
682
-                unset($this->translationInDefaultLocale[$oid][$field]);
683
-            }
684
-            if (! $this->translationInDefaultLocale[$oid]) {
685
-                // We removed the final remaining elements from the
686
-                // translationInDefaultLocale[$oid] array, so we might as well
687
-                // completely remove the entry at $oid.
688
-                unset($this->translationInDefaultLocale[$oid]);
689
-            }
690
-        }
691
-    }
692
-
693
-    /**
694
-     * Gets translation object which represents translation in default language.
695
-     * This is for internal use only.
696
-     *
697
-     * @param    string    $oid   hash of the basic entity
698
-     * @param    string    $field field of basic entity
699
-     * @return   mixed     Returns translation object if it exists or NULL otherwise
700
-     */
701
-    private function getTranslationInDefaultLocale($oid, $field)
702
-    {
703
-        if (array_key_exists($oid, $this->translationInDefaultLocale)) {
704
-            if (array_key_exists($field, $this->translationInDefaultLocale[$oid])) {
705
-                $ret = $this->translationInDefaultLocale[$oid][$field];
706
-            } else {
707
-                $ret = null;
708
-            }
709
-        } else {
710
-            $ret = null;
711
-        }
712
-        return $ret;
713
-    }
714
-
715
-    /**
716
-     * Check if object has any translation object which represents translation in default language.
717
-     * This is for internal use only.
718
-     *
719
-     * @param    string    $oid   hash of the basic entity
720
-     * @return   bool
721
-     */
722
-    public function hasTranslationsInDefaultLocale($oid)
723
-    {
724
-        return array_key_exists($oid, $this->translationInDefaultLocale);
725
-    }
726
-     
727
-    /**
728
-     * Checks if the translation entity belongs to the object in question
729
-     *
730
-     * @param   TranslatableAdapter $ea
731
-     * @param   mixed               $trans
732
-     * @param   mixed               $object
733
-     * @return  boolean
734
-     */
735
-    private function belongsToObject(TranslatableAdapter $ea, $trans, $object)
736
-    {
737
-        if ($ea->usesPersonalTranslation(get_class($trans))) {
738
-            return $trans->getObject() === $object;
739
-        }
740
-
741
-        return ($trans->getForeignKey() === $object->getId()
742
-            && ($trans->getObjectClass() === get_class($object)));
743
-    }
744
-}
745
-

+ 0 - 250
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Annotation.php View File

@@ -1,250 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tree\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\AbstractAnnotationDriver,
6
-    Gedmo\Exception\InvalidMappingException,
7
-    Gedmo\Tree\Mapping\Validator;
8
-
9
-/**
10
- * This is an annotation mapping driver for Tree
11
- * behavioral extension. Used for extraction of extended
12
- * metadata from Annotations specificaly for Tree
13
- * extension.
14
- *
15
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
16
- * @author <rocco@roccosportal.com>
17
- * @package Gedmo.Tree.Mapping.Driver
18
- * @subpackage Annotation
19
- * @link http://www.gediminasm.org
20
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
21
- */
22
-class Annotation extends AbstractAnnotationDriver
23
-{
24
-    /**
25
-     * Annotation to define the tree type
26
-     */
27
-    const TREE = 'Gedmo\\Mapping\\Annotation\\Tree';
28
-
29
-    /**
30
-     * Annotation to mark field as one which will store left value
31
-     */
32
-    const LEFT = 'Gedmo\\Mapping\\Annotation\\TreeLeft';
33
-
34
-    /**
35
-     * Annotation to mark field as one which will store right value
36
-     */
37
-    const RIGHT = 'Gedmo\\Mapping\\Annotation\\TreeRight';
38
-
39
-    /**
40
-     * Annotation to mark relative parent field
41
-     */
42
-    const PARENT = 'Gedmo\\Mapping\\Annotation\\TreeParent';
43
-
44
-    /**
45
-     * Annotation to mark node level
46
-     */
47
-    const LEVEL = 'Gedmo\\Mapping\\Annotation\\TreeLevel';
48
-
49
-    /**
50
-     * Annotation to mark field as tree root
51
-     */
52
-    const ROOT = 'Gedmo\\Mapping\\Annotation\\TreeRoot';
53
-
54
-    /**
55
-     * Annotation to specify closure tree class
56
-     */
57
-    const CLOSURE = 'Gedmo\\Mapping\\Annotation\\TreeClosure';
58
-
59
-    /**
60
-     * Annotation to specify path class
61
-     */
62
-    const PATH = 'Gedmo\\Mapping\\Annotation\\TreePath';
63
-
64
-    /**
65
-     * Annotation to specify path source class
66
-     */
67
-    const PATH_SOURCE = 'Gedmo\\Mapping\\Annotation\\TreePathSource';
68
-
69
-    /**
70
-     * Annotation to specify path hash class
71
-     */
72
-    const PATH_HASH = 'Gedmo\\Mapping\\Annotation\\TreePathHash';
73
-
74
-    /**
75
-     * Annotation to mark the field to be used to hold the lock time
76
-     */
77
-    const LOCK_TIME = 'Gedmo\\Mapping\\Annotation\\TreeLockTime';
78
-
79
-    /**
80
-     * List of tree strategies available
81
-     *
82
-     * @var array
83
-     */
84
-    protected $strategies = array(
85
-        'nested',
86
-        'closure',
87
-        'materializedPath'
88
-    );
89
-
90
-    /**
91
-     * {@inheritDoc}
92
-     */
93
-    public function readExtendedMetadata($meta, array &$config)
94
-    {
95
-        $validator = new Validator();
96
-        $class = $this->getMetaReflectionClass($meta);
97
-        // class annotations
98
-        if ($annot = $this->reader->getClassAnnotation($class, self::TREE)) {
99
-            if (!in_array($annot->type, $this->strategies)) {
100
-                throw new InvalidMappingException("Tree type: {$annot->type} is not available.");
101
-            }
102
-            $config['strategy'] = $annot->type;
103
-            $config['activate_locking'] = $annot->activateLocking;
104
-            $config['locking_timeout'] = (int) $annot->lockingTimeout;
105
-
106
-            if ($config['locking_timeout'] < 1) {
107
-                throw new InvalidMappingException("Tree Locking Timeout must be at least of 1 second.");
108
-            }
109
-        }
110
-        if ($annot = $this->reader->getClassAnnotation($class, self::CLOSURE)) {
111
-            if (!class_exists($annot->class)) {
112
-                throw new InvalidMappingException("Tree closure class: {$annot->class} does not exist.");
113
-            }
114
-            $config['closure'] = $annot->class;
115
-        }
116
-
117
-        // property annotations
118
-        foreach ($class->getProperties() as $property) {
119
-            if ($meta->isMappedSuperclass && !$property->isPrivate() ||
120
-                $meta->isInheritedField($property->name) ||
121
-                isset($meta->associationMappings[$property->name]['inherited'])
122
-            ) {
123
-                continue;
124
-            }
125
-            // left
126
-            if ($this->reader->getPropertyAnnotation($property, self::LEFT)) {
127
-                $field = $property->getName();
128
-                if (!$meta->hasField($field)) {
129
-                    throw new InvalidMappingException("Unable to find 'left' - [{$field}] as mapped property in entity - {$meta->name}");
130
-                }
131
-                if (!$validator->isValidField($meta, $field)) {
132
-                    throw new InvalidMappingException("Tree left field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
133
-                }
134
-                $config['left'] = $field;
135
-            }
136
-            // right
137
-            if ($this->reader->getPropertyAnnotation($property, self::RIGHT)) {
138
-                $field = $property->getName();
139
-                if (!$meta->hasField($field)) {
140
-                    throw new InvalidMappingException("Unable to find 'right' - [{$field}] as mapped property in entity - {$meta->name}");
141
-                }
142
-                if (!$validator->isValidField($meta, $field)) {
143
-                    throw new InvalidMappingException("Tree right field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
144
-                }
145
-                $config['right'] = $field;
146
-            }
147
-            // ancestor/parent
148
-            if ($this->reader->getPropertyAnnotation($property, self::PARENT)) {
149
-                $field = $property->getName();
150
-                if (!$meta->isSingleValuedAssociation($field)) {
151
-                    throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
152
-                }
153
-                $config['parent'] = $field;
154
-            }
155
-            // root
156
-            if ($this->reader->getPropertyAnnotation($property, self::ROOT)) {
157
-                $field = $property->getName();
158
-                if (!$meta->hasField($field)) {
159
-                    throw new InvalidMappingException("Unable to find 'root' - [{$field}] as mapped property in entity - {$meta->name}");
160
-                }
161
-
162
-                if (!$validator->isValidFieldForRoot($meta, $field)) {
163
-                    throw new InvalidMappingException("Tree root field - [{$field}] type is not valid and must be any of the 'integer' types or 'string' in class - {$meta->name}");
164
-                }
165
-                $config['root'] = $field;
166
-            }
167
-            // level
168
-            if ($this->reader->getPropertyAnnotation($property, self::LEVEL)) {
169
-                $field = $property->getName();
170
-                if (!$meta->hasField($field)) {
171
-                    throw new InvalidMappingException("Unable to find 'level' - [{$field}] as mapped property in entity - {$meta->name}");
172
-                }
173
-                if (!$validator->isValidField($meta, $field)) {
174
-                    throw new InvalidMappingException("Tree level field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
175
-                }
176
-                $config['level'] = $field;
177
-            }
178
-            // path
179
-            if ($pathAnnotation = $this->reader->getPropertyAnnotation($property, self::PATH)) {
180
-                $field = $property->getName();
181
-                if (!$meta->hasField($field)) {
182
-                    throw new InvalidMappingException("Unable to find 'path' - [{$field}] as mapped property in entity - {$meta->name}");
183
-                }
184
-                if (!$validator->isValidFieldForPath($meta, $field)) {
185
-                    throw new InvalidMappingException("Tree Path field - [{$field}] type is not valid. It must be string or text in class - {$meta->name}");
186
-                }
187
-                if (strlen($pathAnnotation->separator) > 1) {
188
-                    throw new InvalidMappingException("Tree Path field - [{$field}] Separator {$pathAnnotation->separator} is invalid. It must be only one character long.");
189
-                }
190
-                $config['path'] = $field;
191
-                $config['path_separator'] = $pathAnnotation->separator;
192
-                $config['path_append_id'] = $pathAnnotation->appendId;
193
-                $config['path_starts_with_separator'] = $pathAnnotation->startsWithSeparator;
194
-                $config['path_ends_with_separator'] = $pathAnnotation->endsWithSeparator;
195
-            }
196
-            // path source
197
-            if ($this->reader->getPropertyAnnotation($property, self::PATH_SOURCE)) {
198
-                $field = $property->getName();
199
-                if (!$meta->hasField($field)) {
200
-                    throw new InvalidMappingException("Unable to find 'path_source' - [{$field}] as mapped property in entity - {$meta->name}");
201
-                }
202
-                if (!$validator->isValidFieldForPathSource($meta, $field)) {
203
-                    throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
204
-                }
205
-                $config['path_source'] = $field;
206
-            }
207
-
208
-             // path hash
209
-            if ($this->reader->getPropertyAnnotation($property, self::PATH_HASH)) {
210
-                $field = $property->getName();
211
-                if (!$meta->hasField($field)) {
212
-                    throw new InvalidMappingException("Unable to find 'path_hash' - [{$field}] as mapped property in entity - {$meta->name}");
213
-                }
214
-                if (!$validator->isValidFieldForPathHash($meta, $field)) {
215
-                    throw new InvalidMappingException("Tree PathHash field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
216
-                }
217
-                $config['path_hash'] = $field;
218
-
219
-            }
220
-            // lock time
221
-
222
-            if ($this->reader->getPropertyAnnotation($property, self::LOCK_TIME)) {
223
-                $field = $property->getName();
224
-                if (!$meta->hasField($field)) {
225
-                    throw new InvalidMappingException("Unable to find 'lock_time' - [{$field}] as mapped property in entity - {$meta->name}");
226
-                }
227
-                if (!$validator->isValidFieldForLockTime($meta, $field)) {
228
-                    throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It must be \"date\" in class - {$meta->name}");
229
-                }
230
-                $config['lock_time'] = $field;
231
-            }
232
-        }
233
-
234
-        if (isset($config['activate_locking']) && $config['activate_locking'] && !isset($config['lock_time'])) {
235
-            throw new InvalidMappingException("You need to map a date field as the tree lock time field to activate locking support.");
236
-        }
237
-
238
-        if (!$meta->isMappedSuperclass && $config) {
239
-            if (isset($config['strategy'])) {
240
-                if (is_array($meta->identifier) && count($meta->identifier) > 1) {
241
-                    throw new InvalidMappingException("Tree does not support composite identifiers in class - {$meta->name}");
242
-                }
243
-                $method = 'validate' . ucfirst($config['strategy']) . 'TreeMetadata';
244
-                $validator->$method($meta, $config);
245
-            } else {
246
-                throw new InvalidMappingException("Cannot find Tree type for class: {$meta->name}");
247
-            }
248
-        }
249
-    }
250
-}

+ 0 - 197
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Driver/Yaml.php View File

@@ -1,197 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tree\Mapping\Driver;
4
-
5
-use Gedmo\Mapping\Driver\File,
6
-    Gedmo\Mapping\Driver,
7
-    Gedmo\Exception\InvalidMappingException,
8
-    Gedmo\Tree\Mapping\Validator;
9
-
10
-/**
11
- * This is a yaml mapping driver for Tree
12
- * behavioral extension. Used for extraction of extended
13
- * metadata from yaml specificaly for Tree
14
- * extension.
15
- *
16
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
17
- * @package Gedmo.Tree.Mapping.Driver
18
- * @subpackage Yaml
19
- * @link http://www.gediminasm.org
20
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
21
- */
22
-class Yaml extends File implements Driver
23
-{
24
-    /**
25
-     * File extension
26
-     * @var string
27
-     */
28
-    protected $_extension = '.dcm.yml';
29
-
30
-    /**
31
-     * List of tree strategies available
32
-     *
33
-     * @var array
34
-     */
35
-    private $strategies = array(
36
-        'nested',
37
-        'closure',
38
-        'materializedPath'
39
-    );
40
-
41
-    /**
42
-     * {@inheritDoc}
43
-     */
44
-    public function readExtendedMetadata($meta, array &$config)
45
-    {
46
-        $mapping = $this->_getMapping($meta->name);
47
-        $validator = new Validator();
48
-
49
-        if (isset($mapping['gedmo'])) {
50
-            $classMapping = $mapping['gedmo'];
51
-            if (isset($classMapping['tree']['type'])) {
52
-                $strategy = $classMapping['tree']['type'];
53
-                if (!in_array($strategy, $this->strategies)) {
54
-                    throw new InvalidMappingException("Tree type: $strategy is not available.");
55
-                }
56
-                $config['strategy'] = $strategy;
57
-                $config['activate_locking'] = isset($classMapping['tree']['activateLocking']) ?
58
-                    $classMapping['tree']['activateLocking'] : false;
59
-                $config['locking_timeout'] = isset($classMapping['tree']['lockingTimeout']) ?
60
-                    (int) $classMapping['tree']['lockingTimeout'] : 3;
61
-
62
-                if ($config['locking_timeout'] < 1) {
63
-                    throw new InvalidMappingException("Tree Locking Timeout must be at least of 1 second.");
64
-                }
65
-            }
66
-            if (isset($classMapping['tree']['closure'])) {
67
-                $class = $classMapping['tree']['closure'];
68
-                if (!class_exists($class)) {
69
-                    throw new InvalidMappingException("Tree closure class: {$class} does not exist.");
70
-                }
71
-                $config['closure'] = $class;
72
-            }
73
-        }
74
-        if (isset($mapping['fields'])) {
75
-            foreach ($mapping['fields'] as $field => $fieldMapping) {
76
-                if (isset($fieldMapping['gedmo'])) {
77
-                    if (in_array('treeLeft', $fieldMapping['gedmo'])) {
78
-                        if (!$validator->isValidField($meta, $field)) {
79
-                            throw new InvalidMappingException("Tree left field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
80
-                        }
81
-                        $config['left'] = $field;
82
-                    } elseif (in_array('treeRight', $fieldMapping['gedmo'])) {
83
-                        if (!$validator->isValidField($meta, $field)) {
84
-                            throw new InvalidMappingException("Tree right field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
85
-                        }
86
-                        $config['right'] = $field;
87
-                    } elseif (in_array('treeLevel', $fieldMapping['gedmo'])) {
88
-                        if (!$validator->isValidField($meta, $field)) {
89
-                            throw new InvalidMappingException("Tree level field - [{$field}] type is not valid and must be 'integer' in class - {$meta->name}");
90
-                        }
91
-                        $config['level'] = $field;
92
-                    } elseif (in_array('treeRoot', $fieldMapping['gedmo'])) {
93
-                        if (!$validator->isValidFieldForRoot($meta, $field)) {
94
-                            throw new InvalidMappingException("Tree root field - [{$field}] type is not valid and must be any of the 'integer' types or 'string' in class - {$meta->name}");
95
-                        }
96
-                        $config['root'] = $field;
97
-                    } elseif (in_array('treePath', $fieldMapping['gedmo']) || isset($fieldMapping['gedmo']['treePath'])) {
98
-                        if (!$validator->isValidFieldForPath($meta, $field)) {
99
-                            throw new InvalidMappingException("Tree Path field - [{$field}] type is not valid. It must be string or text in class - {$meta->name}");
100
-                        }
101
-
102
-                        $treePathInfo = isset($fieldMapping['gedmo']['treePath']) ? $fieldMapping['gedmo']['treePath'] :
103
-                            $fieldMapping['gedmo'][array_search('treePath', $fieldMapping['gedmo'])];
104
-
105
-                        if (is_array($treePathInfo) && isset($treePathInfo['separator'])) {
106
-                            $separator = $treePathInfo['separator'];
107
-                        } else {
108
-                            $separator = '|';
109
-                        }
110
-
111
-                        if (strlen($separator) > 1) {
112
-                            throw new InvalidMappingException("Tree Path field - [{$field}] Separator {$separator} is invalid. It must be only one character long.");
113
-                        }
114
-
115
-                        if (is_array($treePathInfo) && isset($treePathInfo['appendId'])) {
116
-                            $appendId = $treePathInfo['appendId'];
117
-                        } else {
118
-                            $appendId = null;
119
-                        }
120
-
121
-                        if (is_array($treePathInfo) && isset($treePathInfo['startsWithSeparator'])) {
122
-                            $startsWithSeparator = $treePathInfo['startsWithSeparator'];
123
-                        } else {
124
-                            $startsWithSeparator = false;
125
-                        }
126
-
127
-                        if (is_array($treePathInfo) && isset($treePathInfo['endsWithSeparator'])) {
128
-                            $endsWithSeparator = $treePathInfo['endsWithSeparator'];
129
-                        } else {
130
-                            $endsWithSeparator = true;
131
-                        }
132
-
133
-                        $config['path'] = $field;
134
-                        $config['path_separator'] = $separator;
135
-                        $config['path_append_id'] = $appendId;
136
-                        $config['path_starts_with_separator'] = $startsWithSeparator;
137
-                        $config['path_ends_with_separator'] = $endsWithSeparator;
138
-                    } elseif (in_array('treePathSource', $fieldMapping['gedmo'])) {
139
-                        if (!$validator->isValidFieldForPathSource($meta, $field)) {
140
-                            throw new InvalidMappingException("Tree PathSource field - [{$field}] type is not valid. It can be any of the integer variants, double, float or string in class - {$meta->name}");
141
-                        }
142
-                        $config['path_source'] = $field;
143
-                    } elseif (in_array('treePathHash', $fieldMapping['gedmo'])) {
144
-                        if (!$validator->isValidFieldForPathSource($meta, $field)) {
145
-                            throw new InvalidMappingException("Tree PathHash field - [{$field}] type is not valid and must be 'string' in class - {$meta->name}");
146
-                        }
147
-                        $config['path_hash'] = $field;
148
-                    } elseif (in_array('treeLockTime', $fieldMapping['gedmo'])) {
149
-                        if (!$validator->isValidFieldForLocktime($meta, $field)) {
150
-                            throw new InvalidMappingException("Tree LockTime field - [{$field}] type is not valid. It must be \"date\" in class - {$meta->name}");
151
-                        }
152
-                        $config['lock_time'] = $field;
153
-                    } elseif (in_array('treeParent', $fieldMapping['gedmo'])) {
154
-                        $config['parent'] = $field;
155
-                    }
156
-                }
157
-            }
158
-        }
159
-
160
-        if (isset($config['activate_locking']) && $config['activate_locking'] && !isset($config['lock_time'])) {
161
-            throw new InvalidMappingException("You need to map a date|datetime|timestamp field as the tree lock time field to activate locking support.");
162
-        }
163
-
164
-        if (isset($mapping['manyToOne'])) {
165
-            foreach ($mapping['manyToOne'] as $field => $relationMapping) {
166
-                if (isset($relationMapping['gedmo'])) {
167
-                    if (in_array('treeParent', $relationMapping['gedmo'])) {
168
-                        if ($relationMapping['targetEntity'] != $meta->name) {
169
-                            throw new InvalidMappingException("Unable to find ancestor/parent child relation through ancestor field - [{$field}] in class - {$meta->name}");
170
-                        }
171
-                        $config['parent'] = $field;
172
-                    }
173
-                }
174
-            }
175
-        }
176
-
177
-        if (!$meta->isMappedSuperclass && $config) {
178
-            if (isset($config['strategy'])) {
179
-                if (is_array($meta->identifier) && count($meta->identifier) > 1) {
180
-                    throw new InvalidMappingException("Tree does not support composite identifiers in class - {$meta->name}");
181
-                }
182
-                $method = 'validate' . ucfirst($config['strategy']) . 'TreeMetadata';
183
-                $validator->$method($meta, $config);
184
-            } else {
185
-                throw new InvalidMappingException("Cannot find Tree type for class: {$meta->name}");
186
-            }
187
-        }
188
-    }
189
-
190
-    /**
191
-     * {@inheritDoc}
192
-     */
193
-    protected function _loadMappingFile($file)
194
-    {
195
-        return \Symfony\Component\Yaml\Yaml::parse($file);
196
-    }
197
-}

+ 0 - 230
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Mapping/Validator.php View File

@@ -1,230 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tree\Mapping;
4
-
5
-use Gedmo\Exception\InvalidMappingException;
6
-
7
-/**
8
- * This is a validator for all mapping drivers for Tree
9
- * behavioral extension, containing methods to validate
10
- * mapping information
11
- *
12
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
13
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
14
- * @author <rocco@roccosportal.com>
15
- * @package Gedmo.Tree.Mapping
16
- * @subpackage Validator
17
- * @link http://www.gediminasm.org
18
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
19
- */
20
-class Validator
21
-{
22
-    /**
23
-     * List of types which are valid for tree fields
24
-     *
25
-     * @var array
26
-     */
27
-    private $validTypes = array(
28
-        'integer',
29
-        'smallint',
30
-        'bigint',
31
-        'int'
32
-    );
33
-
34
-    /**
35
-     * List of types which are valid for the path (materialized path strategy)
36
-     *
37
-     * @var array
38
-     */
39
-    private $validPathTypes = array(
40
-        'string',
41
-        'text'
42
-    );
43
-
44
-    /**
45
-     * List of types which are valid for the path source (materialized path strategy)
46
-     *
47
-     * @var array
48
-     */
49
-    private $validPathSourceTypes = array(
50
-        'id',
51
-        'integer',
52
-        'smallint',
53
-        'bigint',
54
-        'string',
55
-        'int',
56
-        'float'
57
-    );
58
-
59
-    /**
60
-     * List of types which are valid for the path hash (materialized path strategy)
61
-     *
62
-     * @var array
63
-     */
64
-    private $validPathHashTypes = array(
65
-        'string'
66
-    );
67
-
68
-    /**
69
-     * List of types which are valid for the path source (materialized path strategy)
70
-     *
71
-     * @var array
72
-     */
73
-    private $validRootTypes = array(
74
-        'integer',
75
-        'smallint',
76
-        'bigint',
77
-        'int',
78
-        'string'
79
-    );
80
-
81
-    /**
82
-     * Checks if $field type is valid
83
-     *
84
-     * @param object $meta
85
-     * @param string $field
86
-     * @return boolean
87
-     */
88
-    public function isValidField($meta, $field)
89
-    {
90
-        $mapping = $meta->getFieldMapping($field);
91
-        return $mapping && in_array($mapping['type'], $this->validTypes);
92
-    }
93
-
94
-    /**
95
-     * Checks if $field type is valid for Path field
96
-     *
97
-     * @param object $meta
98
-     * @param string $field
99
-     * @return boolean
100
-     */
101
-    public function isValidFieldForPath($meta, $field)
102
-    {
103
-        $mapping = $meta->getFieldMapping($field);
104
-        return $mapping && in_array($mapping['type'], $this->validPathTypes);
105
-    }
106
-
107
-    /**
108
-     * Checks if $field type is valid for PathSource field
109
-     *
110
-     * @param object $meta
111
-     * @param string $field
112
-     * @return boolean
113
-     */
114
-    public function isValidFieldForPathSource($meta, $field)
115
-    {
116
-        $mapping = $meta->getFieldMapping($field);
117
-        return $mapping && in_array($mapping['type'], $this->validPathSourceTypes);
118
-    }
119
-
120
-    /**
121
-     * Checks if $field type is valid for PathHash field
122
-     *
123
-     * @param object $meta
124
-     * @param string $field
125
-     * @return boolean
126
-     */
127
-    public function isValidFieldForPathHash($meta, $field)
128
-    {
129
-        $mapping = $meta->getFieldMapping($field);
130
-        return $mapping && in_array($mapping['type'], $this->validPathHashTypes);
131
-    }
132
-
133
-    /**
134
-     * Checks if $field type is valid for LockTime field
135
-     *
136
-     * @param object $meta
137
-     * @param string $field
138
-     * @return boolean
139
-     */
140
-    public function isValidFieldForLockTime($meta, $field)
141
-    {
142
-        $mapping = $meta->getFieldMapping($field);
143
-        return $mapping && ($mapping['type'] === 'date' || $mapping['type'] === 'datetime' || $mapping['type'] === 'timestamp');
144
-    }
145
-
146
-    /**
147
-     * Checks if $field type is valid for Root field
148
-     *
149
-     * @param object $meta
150
-     * @param string $field
151
-     * @return boolean
152
-     */
153
-    public function isValidFieldForRoot($meta, $field)
154
-    {
155
-        $mapping = $meta->getFieldMapping($field);
156
-        return $mapping && in_array($mapping['type'], $this->validRootTypes);
157
-    }
158
-
159
-    /**
160
-     * Validates metadata for nested type tree
161
-     *
162
-     * @param object $meta
163
-     * @param array $config
164
-     * @throws InvalidMappingException
165
-     * @return void
166
-     */
167
-    public function validateNestedTreeMetadata($meta, array $config)
168
-    {
169
-        $missingFields = array();
170
-        if (!isset($config['parent'])) {
171
-            $missingFields[] = 'ancestor';
172
-        }
173
-        if (!isset($config['left'])) {
174
-            $missingFields[] = 'left';
175
-        }
176
-        if (!isset($config['right'])) {
177
-            $missingFields[] = 'right';
178
-        }
179
-        if ($missingFields) {
180
-            throw new InvalidMappingException("Missing properties: " . implode(', ', $missingFields) . " in class - {$meta->name}");
181
-        }
182
-    }
183
-
184
-    /**
185
-     * Validates metadata for closure type tree
186
-     *
187
-     * @param object $meta
188
-     * @param array $config
189
-     * @throws InvalidMappingException
190
-     * @return void
191
-     */
192
-    public function validateClosureTreeMetadata($meta, array $config)
193
-    {
194
-        $missingFields = array();
195
-        if (!isset($config['parent'])) {
196
-            $missingFields[] = 'ancestor';
197
-        }
198
-        if (!isset($config['closure'])) {
199
-            $missingFields[] = 'closure class';
200
-        }
201
-        if ($missingFields) {
202
-            throw new InvalidMappingException("Missing properties: " . implode(', ', $missingFields) . " in class - {$meta->name}");
203
-        }
204
-    }
205
-
206
-    /**
207
-     * Validates metadata for materialized path type tree
208
-     *
209
-     * @param object $meta
210
-     * @param array $config
211
-     * @throws InvalidMappingException
212
-     * @return void
213
-     */
214
-    public function validateMaterializedPathTreeMetadata($meta, array $config)
215
-    {
216
-        $missingFields = array();
217
-        if (!isset($config['parent'])) {
218
-            $missingFields[] = 'ancestor';
219
-        }
220
-        if (!isset($config['path'])) {
221
-            $missingFields[] = 'path';
222
-        }
223
-        if (!isset($config['path_source'])) {
224
-            $missingFields[] = 'path_source';
225
-        }
226
-        if ($missingFields) {
227
-            throw new InvalidMappingException("Missing properties: " . implode(', ', $missingFields) . " in class - {$meta->name}");
228
-        }
229
-    }
230
-}

+ 0 - 514
vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Strategy/AbstractMaterializedPath.php View File

@@ -1,514 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tree\Strategy;
4
-
5
-use Gedmo\Tree\Strategy;
6
-use Doctrine\ORM\EntityManager;
7
-use Gedmo\Tree\TreeListener;
8
-use Doctrine\ORM\Mapping\ClassMetadataInfo;
9
-use Doctrine\ORM\Query;
10
-use Doctrine\Common\Persistence\ObjectManager;
11
-use Gedmo\Mapping\Event\AdapterInterface;
12
-use Gedmo\Exception\RuntimeException;
13
-use Gedmo\Exception\TreeLockingException;
14
-
15
-/**
16
- * This strategy makes tree using materialized path strategy
17
- *
18
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
19
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
20
- * @author <rocco@roccosportal.com>
21
- * @package Gedmo.Tree.Strategy
22
- * @subpackage AbstractMaterializedPath
23
- * @link http://www.gediminasm.org
24
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
25
- */
26
-
27
-abstract class AbstractMaterializedPath implements Strategy
28
-{
29
-    const ACTION_INSERT = 'insert';
30
-    const ACTION_UPDATE = 'update';
31
-    const ACTION_REMOVE = 'remove';
32
-
33
-    /**
34
-     * TreeListener
35
-     *
36
-     * @var AbstractTreeListener
37
-     */
38
-    protected $listener = null;
39
-
40
-    /**
41
-     * Array of objects which were scheduled for path processes
42
-     *
43
-     * @var array
44
-     */
45
-    protected $scheduledForPathProcess = array();
46
-
47
-    /**
48
-     * Array of objects which were scheduled for path process.
49
-     * This time, this array contains the objects with their ID
50
-     * already set
51
-     *
52
-     * @var array
53
-     */
54
-    protected $scheduledForPathProcessWithIdSet = array();
55
-
56
-    /**
57
-     * Roots of trees which needs to be locked
58
-     *
59
-     * @var array
60
-     */
61
-    protected $rootsOfTreesWhichNeedsLocking = array();
62
-
63
-    /**
64
-     * Objects which are going to be inserted (set only if tree locking is used)
65
-     *
66
-     * @var array
67
-     */
68
-    protected $pendingObjectsToInsert = array();
69
-
70
-    /**
71
-     * Objects which are going to be updated (set only if tree locking is used)
72
-     *
73
-     * @var array
74
-     */
75
-    protected $pendingObjectsToUpdate = array();
76
-
77
-    /**
78
-     * Objects which are going to be removed (set only if tree locking is used)
79
-     *
80
-     * @var array
81
-     */
82
-    protected $pendingObjectsToRemove = array();
83
-
84
-    /**
85
-     * {@inheritdoc}
86
-     */
87
-    public function __construct(TreeListener $listener)
88
-    {
89
-        $this->listener = $listener;
90
-    }
91
-
92
-    /**
93
-     * {@inheritdoc}
94
-     */
95
-    public function getName()
96
-    {
97
-        return Strategy::MATERIALIZED_PATH;
98
-    }
99
-
100
-    /**
101
-     * {@inheritdoc}
102
-     */
103
-    public function processScheduledInsertion($om, $node, AdapterInterface $ea)
104
-    {
105
-        $meta = $om->getClassMetadata(get_class($node));
106
-        $config = $this->listener->getConfiguration($om, $meta->name);
107
-        $fieldMapping = $meta->getFieldMapping($config['path_source']);
108
-
109
-        if ($meta->isIdentifier($config['path_source']) || $fieldMapping['type'] === 'string') {
110
-            $this->scheduledForPathProcess[spl_object_hash($node)] = $node;
111
-        } else {
112
-            $this->updateNode($om, $node, $ea);
113
-        }
114
-    }
115
-
116
-    /**
117
-     * {@inheritdoc}
118
-     */
119
-    public function processScheduledUpdate($om, $node, AdapterInterface $ea)
120
-    {
121
-        $meta = $om->getClassMetadata(get_class($node));
122
-        $config = $this->listener->getConfiguration($om, $meta->name);
123
-        $uow = $om->getUnitOfWork();
124
-        $changeSet = $ea->getObjectChangeSet($uow, $node);
125
-
126
-        if (isset($changeSet[$config['parent']]) || isset($changeSet[$config['path_source']])) {
127
-            if (isset($changeSet[$config['path']])) {
128
-                $originalPath = $changeSet[$config['path']][0];
129
-            } else {
130
-                $pathProp = $meta->getReflectionProperty($config['path']);
131
-                $pathProp->setAccessible(true);
132
-                $originalPath = $pathProp->getValue($node);
133
-            }
134
-
135
-            $this->updateNode($om, $node, $ea);
136
-            $this->updateChildren($om, $node, $ea, $originalPath);
137
-        }
138
-    }
139
-
140
-    /**
141
-     * {@inheritdoc}
142
-     */
143
-    public function processPostPersist($om, $node, AdapterInterface $ea)
144
-    {
145
-        $oid = spl_object_hash($node);
146
-
147
-        if ($this->scheduledForPathProcess && array_key_exists($oid, $this->scheduledForPathProcess)) {
148
-            $this->scheduledForPathProcessWithIdSet[$oid] = $node;
149
-
150
-            unset($this->scheduledForPathProcess[$oid]);
151
-
152
-            if (empty($this->scheduledForPathProcess)) {
153
-                foreach ($this->scheduledForPathProcessWithIdSet as $oid => $node) {
154
-                    $this->updateNode($om, $node, $ea);
155
-
156
-                    unset($this->scheduledForPathProcessWithIdSet[$oid]);
157
-                }
158
-            }
159
-        }
160
-
161
-        $this->processPostEventsActions($om, $ea, $node, self::ACTION_INSERT);
162
-    }
163
-
164
-    /**
165
-     * {@inheritdoc}
166
-     */
167
-    public function processPostUpdate($om, $node, AdapterInterface $ea)
168
-    {
169
-        $this->processPostEventsActions($om, $ea, $node, self::ACTION_UPDATE);
170
-    }
171
-
172
-    /**
173
-     * {@inheritdoc}
174
-     */
175
-    public function processPostRemove($om, $node, AdapterInterface $ea)
176
-    {
177
-        $this->processPostEventsActions($om, $ea, $node, self::ACTION_REMOVE);
178
-    }
179
-
180
-    /**
181
-     * {@inheritdoc}
182
-     */
183
-    public function onFlushEnd($om, AdapterInterface $ea)
184
-    {
185
-        $this->lockTrees($om, $ea);
186
-    }
187
-
188
-    /**
189
-     * {@inheritdoc}
190
-     */
191
-    public function processPreRemove($om, $node)
192
-    {
193
-        $this->processPreLockingActions($om, $node, self::ACTION_REMOVE);
194
-    }
195
-
196
-    /**
197
-     * {@inheritdoc}
198
-     */
199
-    public function processPrePersist($om, $node)
200
-    {
201
-        $this->processPreLockingActions($om, $node, self::ACTION_INSERT);
202
-    }
203
-
204
-    /**
205
-     * {@inheritdoc}
206
-     */
207
-    public function processPreUpdate($om, $node)
208
-    {
209
-        $this->processPreLockingActions($om, $node, self::ACTION_UPDATE);
210
-    }
211
-
212
-    /**
213
-     * {@inheritdoc}
214
-     */
215
-    public function processMetadataLoad($om, $meta)
216
-    {}
217
-
218
-    /**
219
-     * {@inheritdoc}
220
-     */
221
-    public function processScheduledDelete($om, $node)
222
-    {
223
-        $meta = $om->getClassMetadata(get_class($node));
224
-        $config = $this->listener->getConfiguration($om, $meta->name);
225
-
226
-        $this->removeNode($om, $meta, $config, $node);
227
-    }
228
-
229
-    /**
230
-     * Update the $node
231
-     *
232
-     * @param ObjectManager $om
233
-     * @param object $node - target node
234
-     * @param object $ea - event adapter
235
-     * @return void
236
-     */
237
-    public function updateNode(ObjectManager $om, $node, AdapterInterface $ea)
238
-    {
239
-        $oid = spl_object_hash($node);
240
-        $meta = $om->getClassMetadata(get_class($node));
241
-        $config = $this->listener->getConfiguration($om, $meta->name);
242
-        $uow = $om->getUnitOfWork();
243
-        $parentProp = $meta->getReflectionProperty($config['parent']);
244
-        $parentProp->setAccessible(true);
245
-        $parent = $parentProp->getValue($node);
246
-        $pathProp = $meta->getReflectionProperty($config['path']);
247
-        $pathProp->setAccessible(true);
248
-        $pathSourceProp = $meta->getReflectionProperty($config['path_source']);
249
-        $pathSourceProp->setAccessible(true);
250
-        $path = $pathSourceProp->getValue($node);
251
-
252
-        // We need to avoid the presence of the path separator in the path source
253
-        if (strpos($path, $config['path_separator']) !== false) {
254
-            $msg = 'You can\'t use the Path separator ("%s") as a character for your PathSource field value.';
255
-
256
-            throw new RuntimeException(sprintf($msg, $config['path_separator']));
257
-        }
258
-
259
-        $fieldMapping = $meta->getFieldMapping($config['path_source']);
260
-
261
-        // default behavior: if PathSource field is a string, we append the ID to the path
262
-        // path_append_id is true: always append id
263
-        // path_append_id is false: never append id
264
-        if ($config['path_append_id'] === true || ($fieldMapping['type'] === 'string' && $config['path_append_id']!==false)) {
265
-            if (method_exists($meta, 'getIdentifierValue')) {
266
-                $identifier = $meta->getIdentifierValue($node);
267
-            } else {
268
-                $identifierProp = $meta->getReflectionProperty($meta->getSingleIdentifierFieldName());
269
-                $identifierProp->setAccessible(true);
270
-                $identifier = $identifierProp->getValue($node);
271
-            }
272
-
273
-            $path .= '-'.$identifier;
274
-        }
275
-
276
-
277
-        if ($parent) {
278
-            // Ensure parent has been initialized in the case where it's a proxy
279
-            $om->initializeObject($parent);
280
-
281
-            $changeSet = $uow->isScheduledForUpdate($parent) ? $ea->getObjectChangeSet($uow, $parent) : false;
282
-            $pathOrPathSourceHasChanged = $changeSet && (isset($changeSet[$config['path_source']]) || isset($changeSet[$config['path']]));
283
-
284
-            if ($pathOrPathSourceHasChanged || !$pathProp->getValue($parent)) {
285
-                $this->updateNode($om, $parent, $ea);
286
-            }
287
-
288
-            $parentPath = $pathProp->getValue($parent);
289
-            // if parent path not ends with separator
290
-            if ($parentPath[strlen($parentPath) - 1] !== $config['path_separator']) {
291
-                // add separator
292
-                $path = $pathProp->getValue($parent) . $config['path_separator'] . $path;
293
-            } else {
294
-                // don't add separator
295
-                $path = $pathProp->getValue($parent) . $path;
296
-            }
297
-
298
-        }
299
-
300
-
301
-        if ($config['path_starts_with_separator'] && (strlen($path) > 0 && $path[0] !== $config['path_separator'])) {
302
-            $path = $config['path_separator'] . $path;
303
-        }
304
-
305
-        if ($config['path_ends_with_separator'] && ($path[strlen($path) - 1] !== $config['path_separator'])) {
306
-            $path .= $config['path_separator'];
307
-        }
308
-
309
-        $pathProp->setValue($node, $path);
310
-        $changes = array(
311
-            $config['path'] => array(null, $path)
312
-        );
313
-
314
-        if (isset($config['path_hash'])) {
315
-            $pathHash = md5($path);
316
-            $pathHashProp = $meta->getReflectionProperty($config['path_hash']);
317
-            $pathHashProp->setAccessible(true);
318
-            $pathHashProp->setValue($node, $pathHash);
319
-            $changes[$config['path_hash']] = array(null, $pathHash);
320
-        }
321
-
322
-
323
-        if (isset($config['level'])) {
324
-            $level = substr_count($path, $config['path_separator']);
325
-            $levelProp = $meta->getReflectionProperty($config['level']);
326
-            $levelProp->setAccessible(true);
327
-            $levelProp->setValue($node, $level);
328
-            $changes[$config['level']] = array(null, $level);
329
-        }
330
-
331
-        $uow->scheduleExtraUpdate($node, $changes);
332
-        $ea->setOriginalObjectProperty($uow, $oid, $config['path'], $path);
333
-
334
-        if(isset($config['path_hash'])){
335
-            $ea->setOriginalObjectProperty($uow, $oid, $config['path_hash'], $pathHash);
336
-        }
337
-    }
338
-
339
-    /**
340
-     * Update node's children
341
-     *
342
-     * @param ObjectManager $om
343
-     * @param object $node
344
-     * @param AdapterInterface $ea
345
-     * @param string $originalPath
346
-     * @return void
347
-     */
348
-    public function updateChildren(ObjectManager $om, $node, AdapterInterface $ea, $originalPath)
349
-    {
350
-        $meta = $om->getClassMetadata(get_class($node));
351
-        $config = $this->listener->getConfiguration($om, $meta->name);
352
-        $children = $this->getChildren($om, $meta, $config, $originalPath);
353
-
354
-        foreach ($children as $child) {
355
-            $this->updateNode($om, $child, $ea);
356
-        }
357
-    }
358
-
359
-    /**
360
-     * Process pre-locking actions
361
-     *
362
-     * @param ObjectManager $om
363
-     * @param object $node
364
-     * @param string $action
365
-     * @return void
366
-     */
367
-    public function processPreLockingActions($om, $node, $action)
368
-    {
369
-        $meta = $om->getClassMetadata(get_class($node));
370
-        $config = $this->listener->getConfiguration($om, $meta->name);
371
-
372
-        if ($config['activate_locking']) {;
373
-            $parentProp = $meta->getReflectionProperty($config['parent']);
374
-            $parentProp->setAccessible(true);
375
-            $parentNode = $node;
376
-
377
-            while (!is_null($parent = $parentProp->getValue($parentNode))) {
378
-                $parentNode = $parent;
379
-            }
380
-
381
-            // In some cases, the parent could be a not initialized proxy. In this case, the
382
-            // "lockTime" field may NOT be loaded yet and have null instead of the date.
383
-            // We need to be sure that this field has its real value
384
-            if ($parentNode !== $node && $parentNode instanceof \Doctrine\ODM\MongoDB\Proxy\Proxy) {
385
-                $reflMethod = new \ReflectionMethod(get_class($parentNode), '__load');
386
-                $reflMethod->setAccessible(true);
387
-
388
-                $reflMethod->invoke($parentNode);
389
-            }
390
-
391
-            // If tree is already locked, we throw an exception
392
-            $lockTimeProp = $meta->getReflectionProperty($config['lock_time']);
393
-            $lockTimeProp->setAccessible(true);
394
-            $lockTime = $lockTimeProp->getValue($parentNode);
395
-
396
-            if (!is_null($lockTime)) {
397
-                $lockTime = $lockTime instanceof \MongoDate ? $lockTime->sec : $lockTime->getTimestamp();
398
-            }
399
-
400
-            if (!is_null($lockTime) && ($lockTime >= (time() - $config['locking_timeout']))) {
401
-                $msg = 'Tree with root id "%s" is locked.';
402
-                $id = $meta->getIdentifierValue($parentNode);
403
-
404
-                throw new TreeLockingException(sprintf($msg, $id));
405
-            }
406
-
407
-            $this->rootsOfTreesWhichNeedsLocking[spl_object_hash($parentNode)] = $parentNode;
408
-
409
-            $oid = spl_object_hash($node);
410
-
411
-            switch ($action) {
412
-                case self::ACTION_INSERT:
413
-                    $this->pendingObjectsToInsert[$oid] = $node;
414
-
415
-                    break;
416
-                case self::ACTION_UPDATE:
417
-                    $this->pendingObjectsToUpdate[$oid] = $node;
418
-
419
-                    break;
420
-                case self::ACTION_REMOVE:
421
-                    $this->pendingObjectsToRemove[$oid] = $node;
422
-
423
-                    break;
424
-                default:
425
-                    throw new \InvalidArgumentException(sprintf('"%s" is not a valid action.', $action));
426
-            }
427
-        }
428
-    }
429
-
430
-    /**
431
-     * Process pre-locking actions
432
-     *
433
-     * @param ObjectManager $om
434
-     * @param AdapterInterface $ea
435
-     * @param object $node
436
-     * @param string $action
437
-     * @return void
438
-     */
439
-    public function processPostEventsActions(ObjectManager $om, AdapterInterface $ea, $node, $action)
440
-    {
441
-        $meta = $om->getClassMetadata(get_class($node));
442
-        $config = $this->listener->getConfiguration($om, $meta->name);
443
-
444
-        if ($config['activate_locking']) {
445
-            switch ($action) {
446
-                case self::ACTION_INSERT:
447
-                    unset($this->pendingObjectsToInsert[spl_object_hash($node)]);
448
-
449
-                    break;
450
-                case self::ACTION_UPDATE:
451
-                    unset($this->pendingObjectsToUpdate[spl_object_hash($node)]);
452
-
453
-                    break;
454
-                case self::ACTION_REMOVE:
455
-                    unset($this->pendingObjectsToRemove[spl_object_hash($node)]);
456
-
457
-                    break;
458
-                default:
459
-                    throw new \InvalidArgumentException(sprintf('"%s" is not a valid action.', $action));
460
-            }
461
-
462
-            if (empty($this->pendingObjectsToInsert) && empty($this->pendingObjectsToUpdate) &&
463
-                empty($this->pendingObjectsToRemove)) {
464
-                $this->releaseTreeLocks($om, $ea);
465
-            }
466
-        }
467
-    }
468
-
469
-    /**
470
-     * Locks all needed trees
471
-     *
472
-     * @param ObjectManager $om
473
-     * @param AdapterInterface $ea
474
-     * @return void
475
-     */
476
-    protected function lockTrees(ObjectManager $om, AdapterInterface $ea)
477
-    {
478
-        // Do nothing by default
479
-    }
480
-
481
-    /**
482
-     * Releases all trees which are locked
483
-     *
484
-     * @param ObjectManager $om
485
-     * @param AdapterInterface $ea
486
-     * @return void
487
-     */
488
-    protected function releaseTreeLocks(ObjectManager $om, AdapterInterface $ea)
489
-    {
490
-        // Do nothing by default
491
-    }
492
-
493
-    /**
494
-     * Remove node and its children
495
-     *
496
-     * @param ObjectManager $om
497
-     * @param object $meta - Metadata
498
-     * @param object $config - config
499
-     * @param object $node - node to remove
500
-     * @return void
501
-     */
502
-    abstract public function removeNode($om, $meta, $config, $node);
503
-
504
-    /**
505
-     * Returns children of the node with its original path
506
-     *
507
-     * @param ObjectManager $om
508
-     * @param object $meta - Metadata
509
-     * @param object $config - config
510
-     * @param string $originalPath - original path of object
511
-     * @return Doctrine\ODM\MongoDB\Cursor
512
-     */
513
-    abstract public function getChildren($om, $meta, $config, $originalPath);
514
-}

+ 0 - 28
vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorAlphanumeric.php View File

@@ -1,28 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable\FilenameGenerator;
4
-
5
-/**
6
- * FilenameGeneratorAlphanumeric
7
- *
8
- * This class generates a filename, leaving only lowercase
9
- * alphanumeric characters
10
- *
11
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @package Gedmo.Uploadable.FilenameGenerator
14
- * @subpackage FilenameGeneratorAlphanumeric
15
- * @link http://www.gediminasm.org
16
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
17
- */
18
-
19
-class FilenameGeneratorAlphanumeric implements FilenameGeneratorInterface
20
-{
21
-    /**
22
-     * @inheritDoc
23
-     */
24
-    public static function generate($filename, $extension, $object = null)
25
-    {
26
-        return preg_replace('/[^a-z0-9]+/', '-', strtolower($filename)).$extension;
27
-    }
28
-}

+ 0 - 28
vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorInterface.php View File

@@ -1,28 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable\FilenameGenerator;
4
-
5
-/**
6
- * FilenameGeneratorInterface
7
- *
8
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
9
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
10
- * @package Gedmo.Uploadable.FilenameGenerator
11
- * @subpackage FilenameGeneratorInterface
12
- * @link http://www.gediminasm.org
13
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
14
- */
15
-
16
-interface FilenameGeneratorInterface
17
-{
18
-    /**
19
-     * Generates a new filename
20
-     *
21
-     * @param string - Filename without extension
22
-     * @param string - Extension with dot: .jpg, .gif, etc
23
-     * @param $object
24
-     *
25
-     * @return string
26
-     */
27
-    public static function generate($filename, $extension, $object = null);
28
-}

+ 0 - 25
vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorSha1.php View File

@@ -1,25 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable\FilenameGenerator;
4
-
5
-/**
6
- * FilenameGeneratorSha1
7
- *
8
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
9
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
10
- * @package Gedmo.Uploadable.FilenameGenerator
11
- * @subpackage FilenameGeneratorSha1
12
- * @link http://www.gediminasm.org
13
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
14
- */
15
-
16
-class FilenameGeneratorSha1 implements FilenameGeneratorInterface
17
-{
18
-    /**
19
-     * @inheritDoc
20
-     */
21
-    public static function generate($filename, $extension, $object = null)
22
-    {
23
-        return sha1(uniqid($filename.$extension, true)).$extension;
24
-    }
25
-}

+ 0 - 709
vendor/gedmo/doctrine-extensions/lib/Gedmo/Uploadable/UploadableListener.php View File

@@ -1,709 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable;
4
-
5
-use Doctrine\Common\Persistence\ObjectManager,
6
-    Doctrine\Common\Persistence\Mapping\ClassMetadata,
7
-    Doctrine\ORM\UnitOfWork,
8
-    Gedmo\Mapping\MappedEventSubscriber,
9
-    Doctrine\Common\EventArgs,
10
-    Gedmo\Mapping\Event\AdapterInterface,
11
-    Gedmo\Exception\UploadableDirectoryNotFoundException,
12
-    Gedmo\Exception\UploadablePartialException,
13
-    Gedmo\Exception\UploadableCantWriteException,
14
-    Gedmo\Exception\UploadableExtensionException,
15
-    Gedmo\Exception\UploadableFormSizeException,
16
-    Gedmo\Exception\UploadableIniSizeException,
17
-    Gedmo\Exception\UploadableNoFileException,
18
-    Gedmo\Exception\UploadableNoTmpDirException,
19
-    Gedmo\Exception\UploadableUploadException,
20
-    Gedmo\Exception\UploadableFileAlreadyExistsException,
21
-    Gedmo\Exception\UploadableNoPathDefinedException,
22
-    Gedmo\Exception\UploadableMaxSizeException,
23
-    Gedmo\Exception\UploadableInvalidMimeTypeException,
24
-    Gedmo\Exception\UploadableCouldntGuessMimeTypeException,
25
-    Gedmo\Uploadable\Mapping\Validator,
26
-    Gedmo\Uploadable\FileInfo\FileInfoInterface,
27
-    Gedmo\Uploadable\FileInfo\FileInfoArray,
28
-    Gedmo\Uploadable\MimeType\MimeTypeGuesser,
29
-    Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface,
30
-    Gedmo\Uploadable\MimeType\MimeTypesExtensionsMap,
31
-    Doctrine\Common\NotifyPropertyChanged,
32
-    Gedmo\Uploadable\Events,
33
-    Gedmo\Uploadable\Event\UploadablePreFileProcessEventArgs,
34
-    Gedmo\Uploadable\Event\UploadablePostFileProcessEventArgs;
35
-
36
-/**
37
- * Uploadable listener
38
- *
39
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
40
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
41
- * @package Gedmo.Uploadable
42
- * @subpackage UploadableListener
43
- * @link http://www.gediminasm.org
44
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
45
- */
46
-class UploadableListener extends MappedEventSubscriber
47
-{
48
-    const ACTION_INSERT = 'INSERT';
49
-    const ACTION_UPDATE = 'UPDATE';
50
-
51
-
52
-    /**
53
-     * Default path to move files in
54
-     *
55
-     * @var string
56
-     */
57
-    private $defaultPath;
58
-
59
-    /**
60
-     * Mime type guesser
61
-     *
62
-     * @var Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface
63
-     */
64
-    private $mimeTypeGuesser;
65
-
66
-    /**
67
-     * Default FileInfoInterface class
68
-     *
69
-     * @var string
70
-     */
71
-    private $defaultFileInfoClass = 'Gedmo\Uploadable\FileInfo\FileInfoArray';
72
-
73
-    /**
74
-     * Array of files to remove on postFlush
75
-     *
76
-     * @var array
77
-     */
78
-    private $pendingFileRemovals = array();
79
-
80
-    /**
81
-     * Array of FileInfoInterface objects. The index is the hash of the entity owner
82
-     * of the FileInfoInterface object.
83
-     *
84
-     * @var array
85
-     */
86
-    private $fileInfoObjects = array();
87
-
88
-
89
-
90
-    public function __construct(MimeTypeGuesserInterface $mimeTypeGuesser = null)
91
-    {
92
-        $this->mimeTypeGuesser = $mimeTypeGuesser ? $mimeTypeGuesser : new MimeTypeGuesser();
93
-    }
94
-
95
-    /**
96
-     * {@inheritdoc}
97
-     */
98
-    public function getSubscribedEvents()
99
-    {
100
-        return array(
101
-            'loadClassMetadata',
102
-            'preFlush',
103
-            'onFlush',
104
-            'postFlush'
105
-        );
106
-    }
107
-
108
-    /**
109
-     * This event is needed in special cases where the entity needs to be updated, but it only has the
110
-     * file field modified. Since we can't mark an entity as "dirty" in the "addEntityFileInfo" method,
111
-     * doctrine thinks the entity has no changes, which produces that the "onFlush" event gets never called.
112
-     * Here we mark the entity as dirty, so the "onFlush" event gets called, and the file is processed.
113
-     *
114
-     * @param \Doctrine\Common\EventArgs $args
115
-     */
116
-    public function preFlush(EventArgs $args)
117
-    {
118
-        if (empty($this->fileInfoObjects)) {
119
-            // Nothing to do
120
-            return;
121
-        }
122
-
123
-        $ea = $this->getEventAdapter($args);
124
-        $om = $ea->getObjectManager();
125
-        $uow = $om->getUnitOfWork();
126
-        $first = reset($this->fileInfoObjects);
127
-        $meta = $om->getClassMetadata(get_class($first['entity']));
128
-        $config = $this->getConfiguration($om, $meta->name);
129
-
130
-        foreach ($this->fileInfoObjects as $info) {
131
-            $entity = $info['entity'];
132
-
133
-            // If the entity is in the identity map, it means it will be updated. We need to force the
134
-            // "dirty check" here by "modifying" the path. We are actually setting the same value, but
135
-            // this will mark the entity as dirty, and the "onFlush" event will be fired, even if there's
136
-            // no other change in the entity's fields apart from the file itself.
137
-            if ($uow->isInIdentityMap($entity)) {
138
-                $path = $this->getFilePath($meta, $config, $entity);
139
-
140
-                $uow->propertyChanged($entity, $config['filePathField'], $path, $path);
141
-                $uow->scheduleForUpdate($entity);
142
-            }
143
-        }
144
-    }
145
-
146
-    /**
147
-     * Handle file-uploading depending on the action
148
-     * being done with objects
149
-     *
150
-     * @param \Doctrine\Common\EventArgs $args
151
-     */
152
-    public function onFlush(EventArgs $args)
153
-    {
154
-        $ea = $this->getEventAdapter($args);
155
-        $om = $ea->getObjectManager();
156
-        $uow = $om->getUnitOfWork();
157
-
158
-        // Do we need to upload files?
159
-        foreach ($this->fileInfoObjects as $info) {
160
-            $entity = $info['entity'];
161
-            $scheduledForInsert = $uow->isScheduledForInsert($entity);
162
-            $scheduledForUpdate = $uow->isScheduledForUpdate($entity);
163
-            $action = ($scheduledForInsert || $scheduledForUpdate) ?
164
-                ($scheduledForInsert ? self::ACTION_INSERT : self::ACTION_UPDATE) :
165
-                false;
166
-
167
-            if ($action) {
168
-                $this->processFile($ea, $entity, $action);
169
-            }
170
-        }
171
-
172
-        // Do we need to remove any files?
173
-        foreach ($ea->getScheduledObjectDeletions($uow) as $object) {
174
-            $meta = $om->getClassMetadata(get_class($object));
175
-            
176
-            if ($config = $this->getConfiguration($om, $meta->name)) {
177
-                if (isset($config['uploadable']) && $config['uploadable']) {
178
-                    $this->pendingFileRemovals[] = $this->getFilePath($meta, $config, $object);
179
-                }
180
-            }
181
-        }
182
-    }
183
-
184
-    /**
185
-     * Handle removal of files
186
-     *
187
-     * @param \Doctrine\Common\EventArgs $args
188
-     */
189
-    public function postFlush(EventArgs $args)
190
-    {
191
-        if (!empty($this->pendingFileRemovals)) {
192
-            foreach ($this->pendingFileRemovals as $file) {
193
-                $this->removeFile($file);
194
-            }
195
-
196
-            $this->pendingFileRemovals = array();
197
-        }
198
-
199
-        $this->fileInfoObjects = array();
200
-    }
201
-
202
-    /**
203
-     * If it's a Uploadable object, verify if the file was uploaded.
204
-     * If that's the case, process it.
205
-     *
206
-     * @param \Gedmo\Mapping\Event\AdapterInterface $ea
207
-     * @param $object
208
-     * @param $action
209
-     * @throws \Gedmo\Exception\UploadableNoPathDefinedException
210
-     * @throws \Gedmo\Exception\UploadableCouldntGuessMimeTypeException
211
-     * @throws \Gedmo\Exception\UploadableMaxSizeException
212
-     * @throws \Gedmo\Exception\UploadableInvalidMimeTypeException
213
-     */
214
-    public function processFile(AdapterInterface $ea, $object, $action)
215
-    {
216
-        $oid = spl_object_hash($object);
217
-        $om = $ea->getObjectManager();
218
-        $uow = $om->getUnitOfWork();
219
-        $meta = $om->getClassMetadata(get_class($object));
220
-        $config = $this->getConfiguration($om, $meta->name);
221
-
222
-        if (!$config || !isset($config['uploadable']) || !$config['uploadable']) {
223
-            // Nothing to do
224
-            return;
225
-        }
226
-
227
-        $refl = $meta->getReflectionClass();
228
-        $fileInfo = $this->fileInfoObjects[$oid]['fileInfo'];
229
-        $evm = $om->getEventManager();
230
-
231
-        if ($evm->hasListeners(Events::uploadablePreFileProcess)) {
232
-            $evm->dispatchEvent(Events::uploadablePreFileProcess, new UploadablePreFileProcessEventArgs(
233
-                $this,
234
-                $om,
235
-                $config,
236
-                $fileInfo,
237
-                $object,
238
-                $action
239
-            ));
240
-        }
241
-
242
-        // Validations
243
-        if ($config['maxSize'] > 0 && $fileInfo->getSize() > $config['maxSize']) {
244
-            $msg = 'File "%s" exceeds the maximum allowed size of %d bytes. File size: %d bytes';
245
-
246
-            throw new UploadableMaxSizeException(sprintf($msg,
247
-                $fileInfo->getName(),
248
-                $config['maxSize'],
249
-                $fileInfo->getSize()
250
-            ));
251
-        }
252
-
253
-        $mime = $this->mimeTypeGuesser->guess($fileInfo->getTmpName());
254
-
255
-        if (!$mime) {
256
-            throw new UploadableCouldntGuessMimeTypeException(sprintf('Couldn\'t guess mime type for file "%s".',
257
-                $fileInfo->getName()
258
-            ));
259
-        }
260
-
261
-        if ($config['allowedTypes'] || $config['disallowedTypes']) {
262
-            $ok = $config['allowedTypes'] ? false : true;
263
-            $mimes = $config['allowedTypes'] ? $config['allowedTypes'] : $config['disallowedTypes'];
264
-
265
-            foreach ($mimes as $m) {
266
-                if ($mime === $m) {
267
-                    $ok = $config['allowedTypes'] ? true : false;
268
-
269
-                    break;
270
-                }
271
-            }
272
-
273
-            if (!$ok) {
274
-                throw new UploadableInvalidMimeTypeException(sprintf('Invalid mime type "%s" for file "%s".',
275
-                    $mime,
276
-                    $fileInfo->getName()
277
-                ));
278
-            }
279
-        }
280
-
281
-        $filePathField = $refl->getProperty($config['filePathField']);
282
-        $filePathField->setAccessible(true);
283
-
284
-        $path = $config['path'];
285
-
286
-        if ($path === '') {
287
-            if ($config['pathMethod'] !== '') {
288
-                $pathMethod = $refl->getMethod($config['pathMethod']);
289
-                $pathMethod->setAccessible(true);
290
-                $path = $pathMethod->invoke($object);
291
-            } else if ($this->getDefaultPath() !== null) {
292
-                $path = $this->getDefaultPath();
293
-            } else {
294
-                $msg = 'You have to define the path to save files either in the listener, or in the class "%s"';
295
-
296
-                throw new UploadableNoPathDefinedException(sprintf($msg,
297
-                    $meta->name
298
-                ));
299
-            }
300
-        }
301
-
302
-        Validator::validatePath($path);
303
-
304
-        $path = rtrim($path, '\/');
305
-
306
-        if ($config['fileMimeTypeField']) {
307
-            $fileMimeTypeField = $refl->getProperty($config['fileMimeTypeField']);
308
-            $fileMimeTypeField->setAccessible(true);
309
-        }
310
-
311
-        if ($config['fileSizeField']) {
312
-            $fileSizeField = $refl->getProperty($config['fileSizeField']);
313
-            $fileSizeField->setAccessible(true);
314
-        }
315
-
316
-        if ($action === self::ACTION_UPDATE) {
317
-            // First we add the original file to the pendingFileRemovals array
318
-            $this->pendingFileRemovals[] = $this->getFilePath($meta, $config, $object);
319
-        }
320
-
321
-        // We generate the filename based on configuration
322
-        $generatorNamespace = 'Gedmo\Uploadable\FilenameGenerator';
323
-
324
-        switch ($config['filenameGenerator']) {
325
-            case Validator::FILENAME_GENERATOR_ALPHANUMERIC:
326
-                $generatorClass = $generatorNamespace .'\FilenameGeneratorAlphanumeric';
327
-
328
-                break;
329
-            case Validator::FILENAME_GENERATOR_SHA1:
330
-                $generatorClass = $generatorNamespace .'\FilenameGeneratorSha1';
331
-
332
-                break;
333
-            case Validator::FILENAME_GENERATOR_NONE:
334
-                $generatorClass = false;
335
-
336
-                break;
337
-            default:
338
-                $generatorClass = $config['filenameGenerator'];
339
-        }
340
-
341
-        $info = $this->moveFile($fileInfo, $path, $generatorClass, $config['allowOverwrite'], $config['appendNumber'], $object);
342
-
343
-        // We override the mime type with the guessed one
344
-        $info['fileMimeType'] = $mime;
345
-
346
-        $filePathField->setValue($object, $info['filePath']);
347
-
348
-        if ($config['callback'] !== '') {
349
-            $callbackMethod = $refl->getMethod($config['callback']);
350
-            $callbackMethod->setAccessible(true);
351
-
352
-            $callbackMethod->invokeArgs($object, array($info));
353
-        }
354
-
355
-        $changes = array(
356
-            $config['filePathField'] => array($filePathField->getValue($object), $info['filePath'])
357
-        );
358
-
359
-        if ($config['fileMimeTypeField']) {
360
-            $changes[$config['fileMimeTypeField']] = array($fileMimeTypeField->getValue($object), $info['fileMimeType']);
361
-
362
-            $this->updateField($object, $uow, $ea, $meta, $config['fileMimeTypeField'], $info['fileMimeType']);
363
-        }
364
-
365
-        if ($config['fileSizeField']) {
366
-            $changes[$config['fileSizeField']] = array($fileSizeField->getValue($object), $info['fileSize']);
367
-
368
-            $this->updateField($object, $uow, $ea, $meta, $config['fileSizeField'], $info['fileSize']);
369
-        }
370
-
371
-        $this->updateField($object, $uow, $ea, $meta, $config['filePathField'], $info['filePath']);
372
-
373
-        $ea->recomputeSingleObjectChangeSet($uow, $meta, $object);
374
-
375
-        if ($evm->hasListeners(Events::uploadablePostFileProcess)) {
376
-            $evm->dispatchEvent(Events::uploadablePostFileProcess, new UploadablePostFileProcessEventArgs(
377
-                $this,
378
-                $om,
379
-                $config,
380
-                $fileInfo,
381
-                $object,
382
-                $action
383
-            ));
384
-        }
385
-
386
-        unset($this->fileInfoObjects[$oid]);
387
-    }
388
-
389
-    /**
390
-     * Returns the path of the entity's file
391
-     *
392
-     * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $meta
393
-     * @param array $config
394
-     * @param $object
395
-     * @return mixed
396
-     */
397
-    public function getFilePath(ClassMetadata $meta, array $config, $object)
398
-    {
399
-        $refl = $meta->getReflectionClass();
400
-        $filePathField = $refl->getProperty($config['filePathField']);
401
-        $filePathField->setAccessible(true);
402
-        $filePath = $filePathField->getValue($object);
403
-
404
-        return $filePath;
405
-    }
406
-
407
-    /**
408
-     * Simple wrapper for the function "unlink" to ease testing
409
-     *
410
-     * @param string
411
-     *
412
-     * @return bool
413
-     */
414
-    public function removeFile($filePath)
415
-    {
416
-        if (is_file($filePath)) {
417
-            return unlink($filePath);
418
-        }
419
-
420
-        return false;
421
-    }
422
-
423
-    /**
424
-     * Moves the file to the specified path
425
-     *
426
-     * @param FileInfo\FileInfoInterface $fileInfo
427
-     * @param $path
428
-     * @param bool $filenameGeneratorClass
429
-     * @param bool $overwrite
430
-     * @param bool $appendNumber
431
-     * @param $object
432
-     * @return array
433
-     * @throws \Gedmo\Exception\UploadableUploadException
434
-     * @throws \Gedmo\Exception\UploadableNoFileException
435
-     * @throws \Gedmo\Exception\UploadableExtensionException
436
-     * @throws \Gedmo\Exception\UploadableIniSizeException
437
-     * @throws \Gedmo\Exception\UploadableFormSizeException
438
-     * @throws \Gedmo\Exception\UploadableFileAlreadyExistsException
439
-     * @throws \Gedmo\Exception\UploadablePartialException
440
-     * @throws \Gedmo\Exception\UploadableNoTmpDirException
441
-     * @throws \Gedmo\Exception\UploadableCantWriteException
442
-     */
443
-    public function moveFile(FileInfoInterface $fileInfo, $path, $filenameGeneratorClass = false, $overwrite = false, $appendNumber = false, $object)
444
-    {
445
-        if ($fileInfo->getError() > 0) {
446
-            switch ($fileInfo->getError()) {
447
-                case 1:
448
-                    $msg = 'Size of uploaded file "%s" exceeds limit imposed by directive "upload_max_filesize" in php.ini';
449
-
450
-                    throw new UploadableIniSizeException(sprintf($msg, $fileInfo->getName()));
451
-                case 2:
452
-                    $msg = 'Size of uploaded file "%s" exceeds limit imposed by option MAX_FILE_SIZE in your form.';
453
-
454
-                    throw new UploadableFormSizeException(sprintf($msg, $fileInfo->getName()));
455
-                case 3:
456
-                    $msg = 'File "%s" was partially uploaded.';
457
-
458
-                    throw new UploadablePartialException(sprintf($msg, $fileInfo->getName()));
459
-                case 4:
460
-                    $msg = 'No file was uploaded!';
461
-
462
-                    throw new UploadableNoFileException(sprintf($msg, $fileInfo->getName()));
463
-                case 6:
464
-                    $msg = 'Upload failed. Temp dir is missing.';
465
-
466
-                    throw new UploadableNoTmpDirException($msg);
467
-                case 7:
468
-                    $msg = 'File "%s" couldn\'t be uploaded because directory is not writable.';
469
-
470
-                    throw new UploadableCantWriteException(sprintf($msg, $fileInfo->getName()));
471
-                case 8:
472
-                    $msg = 'A PHP Extension stopped the uploaded for some reason.';
473
-
474
-                    throw new UploadableExtensionException(sprintf($msg, $fileInfo->getName()));
475
-                default:
476
-                    throw new UploadableUploadException(sprintf('There was an unknown problem while uploading file "%s"',
477
-                        $fileInfo->getName()
478
-                    ));
479
-            }
480
-        }
481
-
482
-        $info = array(
483
-            'fileName'          => '',
484
-            'fileExtension'     => '',
485
-            'fileWithoutExt'    => '',
486
-            'filePath'          => '',
487
-            'fileMimeType'      => $fileInfo->getType(),
488
-            'fileSize'          => $fileInfo->getSize()
489
-        );
490
-
491
-        $info['fileName'] = basename($fileInfo->getName());
492
-        $info['filePath'] = $path.'/'.$info['fileName'];
493
-
494
-        $hasExtension = strrpos($info['fileName'], '.');
495
-
496
-        if ($hasExtension) {
497
-            $info['fileExtension'] = substr($info['filePath'], strrpos($info['filePath'], '.'));
498
-            $info['fileWithoutExt'] = substr($info['filePath'], 0, strrpos($info['filePath'], '.'));
499
-        } else {
500
-            $info['fileWithoutExt'] = $info['fileName'];
501
-        }
502
-
503
-        // Now we generate the filename using the configured class
504
-        if ($filenameGeneratorClass) {
505
-            $filename = $filenameGeneratorClass::generate(
506
-                str_replace($path.'/', '', $info['fileWithoutExt']),
507
-                $info['fileExtension'],
508
-                $object
509
-            );
510
-            $info['filePath'] = str_replace(
511
-                '/'.$info['fileName'],
512
-                '/'.$filename,
513
-                $info['filePath']
514
-            );
515
-            $info['fileName'] = $filename;
516
-
517
-            if (($pos = strrpos($info['filePath'], '.')) !== false) {
518
-                $info['fileWithoutExt'] = substr($info['filePath'], 0, $pos);
519
-            } else {
520
-                $info['fileWithoutExt'] = $info['filePath'];
521
-            }
522
-        }
523
-
524
-        if (is_file($info['filePath'])) {
525
-            if ($overwrite) {
526
-                $this->removeFile($info['filePath']);
527
-            } else if ($appendNumber) {
528
-                $counter = 1;
529
-                $info['filePath'] = $info['fileWithoutExt'].'-'.$counter.$info['fileExtension'];
530
-
531
-                do {
532
-                    $info['filePath'] = $info['fileWithoutExt'].'-'.(++$counter).$info['fileExtension'];
533
-                } while (is_file($info['filePath']));
534
-            } else {
535
-                throw new UploadableFileAlreadyExistsException(sprintf('File "%s" already exists!',
536
-                    $info['filePath']
537
-                ));
538
-            }
539
-        }
540
-
541
-        if (!$this->doMoveFile($fileInfo->getTmpName(), $info['filePath'], $fileInfo->isUploadedFile())) {
542
-            throw new UploadableUploadException(sprintf('File "%s" was not uploaded, or there was a problem moving it to the location "%s".',
543
-                $fileInfo->getName(),
544
-                $path
545
-            ));
546
-        }
547
-
548
-        return $info;
549
-    }
550
-
551
-    /**
552
-     * Simple wrapper method used to move the file. If it's an uploaded file
553
-     * it will use the "move_uploaded_file method. If it's not, it will
554
-     * simple move it
555
-     *
556
-     * @param string - Source file
557
-     * @param string - Destination file
558
-     * @param bool - Is an uploaded file?
559
-     *
560
-     * @return bool
561
-     */
562
-    public function doMoveFile($source, $dest, $isUploadedFile = true)
563
-    {
564
-        return $isUploadedFile ? @move_uploaded_file($source, $dest) : @copy($source, $dest);
565
-    }
566
-
567
-    /**
568
-     * Maps additional metadata
569
-     *
570
-     * @param \Doctrine\Common\EventArgs $eventArgs
571
-     */
572
-    public function loadClassMetadata(EventArgs $eventArgs)
573
-    {
574
-        $ea = $this->getEventAdapter($eventArgs);
575
-        $this->loadMetadataForObjectClass($ea->getObjectManager(), $eventArgs->getClassMetadata());
576
-    }
577
-
578
-    /**
579
-     * Sets the default path
580
-     *
581
-     * @param string
582
-     *
583
-     * @return void
584
-     */
585
-    public function setDefaultPath($path)
586
-    {
587
-        $this->defaultPath = $path;
588
-    }
589
-
590
-    /**
591
-     * Returns default path
592
-     *
593
-     * @return string
594
-     */
595
-    public function getDefaultPath()
596
-    {
597
-        return $this->defaultPath;
598
-    }
599
-
600
-    /**
601
-     * Sets file info default class
602
-     *
603
-     * @param string
604
-     *
605
-     * @return void
606
-     */
607
-    public function setDefaultFileInfoClass($defaultFileInfoClass)
608
-    {
609
-        $fileInfoInterface = 'Gedmo\\Uploadable\\FileInfo\\FileInfoInterface';
610
-        $refl = is_string($defaultFileInfoClass) && class_exists($defaultFileInfoClass) ?
611
-            new \ReflectionClass($defaultFileInfoClass) :
612
-            false;
613
-
614
-        if (!$refl || !$refl->implementsInterface($fileInfoInterface)) {
615
-            $msg = sprintf('Default FileInfo class must be a valid class, and it must implement "%s".',
616
-                $fileInfoInterface
617
-            );
618
-
619
-            throw new \Gedmo\Exception\InvalidArgumentException($msg);
620
-        }
621
-
622
-        $this->defaultFileInfoClass = $defaultFileInfoClass;
623
-    }
624
-
625
-    /**
626
-     * Returns file info default class
627
-     *
628
-     * @return string
629
-     */
630
-    public function getDefaultFileInfoClass()
631
-    {
632
-        return $this->defaultFileInfoClass;
633
-    }
634
-
635
-    /**
636
-     * Adds a FileInfoInterface object for the given entity
637
-     *
638
-     * @param $entity
639
-     * @param $fileInfo
640
-     * @throws \RuntimeException
641
-     */
642
-    public function addEntityFileInfo($entity, $fileInfo)
643
-    {
644
-        $fileInfoClass = $this->getDefaultFileInfoClass();
645
-        $fileInfo = is_array($fileInfo) ? new $fileInfoClass($fileInfo) : $fileInfo;
646
-
647
-        if (!is_object($fileInfo) || !($fileInfo instanceof FileInfoInterface)) {
648
-            $msg = 'You must pass an instance of FileInfoInterface or a valid array for entity of class "%s".';
649
-
650
-            throw new \RuntimeException(sprintf($msg,
651
-                get_class($entity)
652
-            ));
653
-        }
654
-
655
-        $this->fileInfoObjects[spl_object_hash($entity)] = array(
656
-            'entity'        => $entity,
657
-            'fileInfo'      => $fileInfo
658
-        );
659
-    }
660
-
661
-    public function getEntityFileInfo($entity)
662
-    {
663
-        $oid = spl_object_hash($entity);
664
-
665
-        if (!isset($this->fileInfoObjects[$oid])) {
666
-            throw new \RuntimeException(sprintf('There\'s no FileInfoInterface object for entity of class "%s".',
667
-                get_class($entity)
668
-            ));
669
-        }
670
-
671
-        return $this->fileInfoObjects[$oid]['fileInfo'];
672
-    }
673
-
674
-    /**
675
-     * {@inheritDoc}
676
-     */
677
-    protected function getNamespace()
678
-    {
679
-        return __NAMESPACE__;
680
-    }
681
-
682
-    /**
683
-     * @param \Gedmo\Uploadable\Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface $mimeTypeGuesser
684
-     */
685
-    public function setMimeTypeGuesser(MimeTypeGuesserInterface $mimeTypeGuesser)
686
-    {
687
-        $this->mimeTypeGuesser = $mimeTypeGuesser;
688
-    }
689
-
690
-    /**
691
-     * @return \Gedmo\Uploadable\Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface
692
-     */
693
-    public function getMimeTypeGuesser()
694
-    {
695
-        return $this->mimeTypeGuesser;
696
-    }
697
-
698
-    protected function updateField($object, $uow, AdapterInterface $ea, $meta, $field, $value, $notifyPropertyChanged = true)
699
-    {
700
-        $property = $meta->getReflectionProperty($field);
701
-        $oldValue = $property->getValue($object);
702
-        $property->setValue($object, $value);
703
-
704
-        if ($notifyPropertyChanged && $object instanceof NotifyPropertyChanged) {
705
-            $uow = $ea->getObjectManager()->getUnitOfWork();
706
-            $uow->propertyChanged($object, $field, $oldValue, $value);
707
-        }
708
-    }
709
-}

+ 0 - 1
vendor/gedmo/doctrine-extensions/schemas/orm/doctrine-extensions-mapping.xsd View File

@@ -1 +0,0 @@
1
-doctrine-extensions-mapping-2-2.xsd

+ 0 - 58
vendor/gedmo/doctrine-extensions/tests/Gedmo/References/Fixture/ODM/MongoDB/Product.php View File

@@ -1,58 +0,0 @@
1
-<?php
2
-
3
-namespace References\Fixture\ODM\MongoDB;
4
-
5
-use Doctrine\Common\Collections\Collection;
6
-use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
7
-use Gedmo\Mapping\Annotation as Gedmo;
8
-
9
-/**
10
- * @ODM\Document
11
- */
12
-class Product
13
-{
14
-    /**
15
-     * @ODM\Id
16
-     */
17
-    private $id;
18
-
19
-    /**
20
-     * @ODM\String
21
-     */
22
-    private $name;
23
-
24
-    /**
25
-     * @Gedmo\ReferenceMany(type="entity", class="References\Fixture\ORM\StockItem", mappedBy="product")
26
-     */
27
-    private $stockItems;
28
-
29
-    public function getId()
30
-    {
31
-        return $this->id;
32
-    }
33
-
34
-    public function setId($id)
35
-    {
36
-        $this->id = $id;
37
-    }
38
-
39
-    public function getName()
40
-    {
41
-        return $this->name;
42
-    }
43
-
44
-    public function setName($name)
45
-    {
46
-        $this->name = $name;
47
-    }
48
-
49
-    public function getStockItems()
50
-    {
51
-        return $this->stockItems;
52
-    }
53
-
54
-    public function setStockItems(Collection $stockItems)
55
-    {
56
-        $this->stockItems = $stockItems;
57
-    }
58
-}

+ 0 - 105
vendor/gedmo/doctrine-extensions/tests/Gedmo/References/Fixture/ORM/StockItem.php View File

@@ -1,105 +0,0 @@
1
-<?php
2
-
3
-namespace References\Fixture\ORM;
4
-
5
-use Doctrine\ORM\Mapping as ORM;
6
-use Gedmo\Mapping\Annotation as Gedmo;
7
-use References\Fixture\ODM\MongoDB\Product;
8
-
9
-/**
10
- * @ORM\Entity
11
- */
12
-class StockItem
13
-{
14
-    /**
15
-     * @ORM\Id
16
-     * @ORM\Column(type="integer")
17
-     * @ORM\GeneratedValue(strategy="IDENTITY")
18
-     */
19
-    private $id;
20
-
21
-    /**
22
-     * @ORM\Column
23
-     */
24
-    private $name;
25
-
26
-    /**
27
-     * @ORM\Column
28
-     */
29
-    private $sku;
30
-
31
-    /**
32
-     * @ORM\Column(type="integer")
33
-     */
34
-    private $quantity;
35
-
36
-    /**
37
-     * @Gedmo\ReferenceOne(type="document", class="References\Fixture\ODM\MongoDB\Product", inversedBy="stockItems", identifier="productId")
38
-     */
39
-    private $product;
40
-
41
-    /**
42
-     * @ORM\Column(type="string")
43
-     */
44
-    private $productId;
45
-
46
-    public function getId()
47
-    {
48
-        return $this->id;
49
-    }
50
-
51
-    public function setId($id)
52
-    {
53
-        $this->id = $id;
54
-    }
55
-
56
-    public function getName()
57
-    {
58
-        return $this->name;
59
-    }
60
-
61
-    public function setName($name)
62
-    {
63
-        $this->name = $name;
64
-    }
65
-
66
-    public function getSku()
67
-    {
68
-        return $this->sku;
69
-    }
70
-
71
-    public function setSku($sku)
72
-    {
73
-        $this->sku = $sku;
74
-    }
75
-
76
-    public function getQuantity()
77
-    {
78
-        return $this->quantity;
79
-    }
80
-
81
-    public function setQuantity($quantity)
82
-    {
83
-        $this->quantity = $quantity;
84
-    }
85
-
86
-    public function setProduct(Product $product)
87
-    {
88
-        $this->product = $product;
89
-    }
90
-
91
-    public function getProduct()
92
-    {
93
-        return $this->product;
94
-    }
95
-
96
-    public function setProductId($productId)
97
-    {
98
-        $this->productId = $productId;
99
-    }
100
-
101
-    public function getProductId()
102
-    {
103
-        return $this->productId;
104
-    }
105
-}

+ 0 - 123
vendor/gedmo/doctrine-extensions/tests/Gedmo/References/ReferencesListenerTest.php View File

@@ -1,123 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\References;
4
-
5
-use Doctrine\Common\Annotations\AnnotationReader;
6
-use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as MongoDBAnnotationDriver;
7
-use Doctrine\ODM\MongoDB\Configuration;
8
-use Doctrine\ORM\Mapping\Driver\AnnotationDriver as ORMAnnotationDriver;
9
-use References\Fixture\ODM\MongoDB\Product;
10
-use References\Fixture\ORM\StockItem;
11
-use Tool\BaseTestCaseOM;
12
-
13
-class ReferencesListenerTest extends BaseTestCaseOM
14
-{
15
-    private $em;
16
-    private $dm;
17
-
18
-    protected function setUp()
19
-    {
20
-        parent::setUp();
21
-
22
-        $reader = new AnnotationReader();
23
-
24
-        $this->dm = $this->getMockDocumentManager('test', new MongoDBAnnotationDriver($reader, __DIR__ . '/Fixture/ODM/MongoDB'));
25
-
26
-        $listener = new ReferencesListener(array(
27
-            'document' => $this->dm
28
-        ));
29
-
30
-        $this->evm->addEventSubscriber($listener);
31
-
32
-        $reader = new AnnotationReader();
33
-
34
-        $this->em = $this->getMockSqliteEntityManager(array('References\Fixture\ORM\StockItem'), new ORMAnnotationDriver($reader, __DIR__ . '/Fixture/ORM'));
35
-
36
-        $listener->registerManager('entity', $this->em);
37
-    }
38
-
39
-    public function testShouldPersistReferencedIdentifiersIntoIdentifierField()
40
-    {
41
-        $stockItem = new StockItem();
42
-        $stockItem->setName('Apple TV');
43
-        $stockItem->setSku('APP-TV');
44
-        $stockItem->setQuantity(25);
45
-
46
-        $product = new Product();
47
-        $product->setName('Apple TV');
48
-
49
-        $this->dm->persist($product);
50
-        $this->dm->flush();
51
-
52
-        $stockItem->setProduct($product);
53
-
54
-        $this->em->persist($stockItem);
55
-
56
-        $this->assertEquals($product->getId(), $stockItem->getProductId());
57
-    }
58
-
59
-    public function testShouldPopulateReferenceOneWithProxyFromIdentifierField()
60
-    {
61
-        $product = new Product();
62
-        $product->setName('Apple TV');
63
-
64
-        $this->dm->persist($product);
65
-        $this->dm->flush();
66
-
67
-        $stockItem = new StockItem();
68
-        $stockItem->setName('Apple TV');
69
-        $stockItem->setSku('APP-TV');
70
-        $stockItem->setQuantity(25);
71
-        $stockItem->setProductId($product->getId());
72
-
73
-        $this->em->persist($stockItem);
74
-        $this->em->flush();
75
-        $this->em->clear();
76
-
77
-        $stockItem = $this->em->find(get_class($stockItem), $stockItem->getId());
78
-
79
-        $this->assertSame($product, $stockItem->getProduct());
80
-    }
81
-
82
-    public function testShouldPopulateReferenceManyWithLazyCollectionInstance()
83
-    {
84
-        $product = new Product();
85
-        $product->setName('Apple TV');
86
-
87
-        $this->dm->persist($product);
88
-        $this->dm->flush();
89
-        $this->dm->clear();
90
-
91
-        $stockItem = new StockItem();
92
-        $stockItem->setName('Apple TV');
93
-        $stockItem->setSku('APP-TV');
94
-        $stockItem->setQuantity(25);
95
-        $stockItem->setProductId($product->getId());
96
-
97
-        $this->em->persist($stockItem);
98
-
99
-        $stockItem = new StockItem();
100
-        $stockItem->setName('Apple TV');
101
-        $stockItem->setSku('AMZN-APP-TV');
102
-        $stockItem->setQuantity(25);
103
-        $stockItem->setProductId($product->getId());
104
-
105
-        $this->em->persist($stockItem);
106
-        $this->em->flush();
107
-
108
-        $product = $this->dm->find(get_class($product), $product->getId());
109
-
110
-        $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $product->getStockItems());
111
-        $this->assertEquals(2, $product->getStockItems()->count());
112
-
113
-        $first = $product->getStockItems()->first();
114
-
115
-        $this->assertInstanceOf(get_class($stockItem), $first);
116
-        $this->assertEquals('APP-TV', $first->getSku());
117
-
118
-        $last = $product->getStockItems()->last();
119
-
120
-        $this->assertInstanceOf(get_class($stockItem), $last);
121
-        $this->assertEquals('AMZN-APP-TV', $last->getSku());
122
-    }
123
-}

+ 0 - 331
vendor/gedmo/doctrine-extensions/tests/Gedmo/Tool/BaseTestCaseOM.php View File

@@ -1,331 +0,0 @@
1
-<?php
2
-
3
-namespace Tool;
4
-
5
-// common
6
-use Doctrine\Common\Annotations\AnnotationReader;
7
-use Doctrine\Common\EventManager;
8
-use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
9
-// orm specific
10
-use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
11
-use Doctrine\ORM\Mapping\DefaultNamingStrategy;
12
-use Doctrine\ORM\Mapping\Driver\Driver as MappingDriverORM;
13
-use Doctrine\ORM\Mapping\Driver\AnnotationDriver as AnnotationDriverORM;
14
-use Doctrine\ORM\EntityManager;
15
-use Doctrine\ORM\Tools\SchemaTool;
16
-// odm specific
17
-use Doctrine\ODM\MongoDB\Mapping\Driver\Driver as MappingDriverODM;
18
-use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as AnnotationDriverODM;
19
-use Doctrine\ODM\MongoDB\DocumentManager;
20
-use Doctrine\MongoDB\Connection;
21
-// listeners
22
-use Gedmo\Translatable\TranslatableListener;
23
-use Gedmo\Sluggable\SluggableListener;
24
-use Gedmo\Tree\TreeListener;
25
-use Gedmo\Timestampable\TimestampableListener;
26
-use Gedmo\Loggable\LoggableListener;
27
-
28
-/**
29
- * Base test case contains common mock objects
30
- * generation methods for multi object manager
31
- * test cases
32
- *
33
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
34
- * @package Gedmo
35
- * @subpackage BaseTestCase
36
- * @link http://www.gediminasm.org
37
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
38
- */
39
-abstract class BaseTestCaseOM extends \PHPUnit_Framework_TestCase
40
-{
41
-    /**
42
-     * @var EventManager
43
-     */
44
-    protected $evm;
45
-
46
-    /**
47
-     * Initialized document managers
48
-     *
49
-     * @var array
50
-     */
51
-    private $dms = array();
52
-
53
-    /**
54
-     * {@inheritdoc}
55
-     */
56
-    protected function setUp()
57
-    {
58
-
59
-    }
60
-
61
-    /**
62
-     * {@inheritdoc}
63
-     */
64
-    protected function tearDown()
65
-    {
66
-        foreach ($this->dms as $dm) {
67
-            if ($dm) {
68
-                foreach ($dm->getDocumentDatabases() as $db) {
69
-                    foreach ($db->listCollections() as $collection) {
70
-                        $collection->drop();
71
-                    }
72
-                }
73
-                $dm->getConnection()->close();
74
-                $dm = null;
75
-            }
76
-        }
77
-    }
78
-
79
-    /**
80
-     * DocumentManager mock object together with
81
-     * annotation mapping driver and database
82
-     *
83
-     * @param string $dbName
84
-     * @param Doctrine\ODM\MongoDB\Mapping\Driver\Driver $mappingDriver
85
-     * @return DocumentManager
86
-     */
87
-    protected function getMockDocumentManager($dbName, MappingDriver $mappingDriver = null)
88
-    {
89
-        if (!class_exists('Mongo')) {
90
-            $this->markTestSkipped('Missing Mongo extension.');
91
-        }
92
-        $conn = new Connection;
93
-        $config = $this->getMockAnnotatedODMMongoDBConfig($dbName, $mappingDriver);
94
-
95
-        $dm = null;
96
-        try {
97
-            $dm = DocumentManager::create($conn, $config, $this->getEventManager());
98
-            $dm->getConnection()->connect();
99
-        } catch (\MongoException $e) {
100
-            $this->markTestSkipped('Doctrine MongoDB ODM failed to connect');
101
-        }
102
-        return $dm;
103
-    }
104
-
105
-    /**
106
-     * DocumentManager mock object with
107
-     * annotation mapping driver
108
-     *
109
-     * @param string $dbName
110
-     * @param Doctrine\ODM\MongoDB\Mapping\Driver\Driver $mappingDriver
111
-     * @return DocumentManager
112
-     */
113
-    protected function getMockMappedDocumentManager($dbName, MappingDriver $mappingDriver = null)
114
-    {
115
-        $conn = $this->getMock('Doctrine\\MongoDB\\Connection');
116
-        $config = $this->getMockAnnotatedODMMongoDBConfig($dbName, $mappingDriver);
117
-
118
-        $dm = DocumentManager::create($conn, $config, $this->getEventManager());
119
-        return $dm;
120
-    }
121
-
122
-    /**
123
-     * EntityManager mock object together with
124
-     * annotation mapping driver and pdo_sqlite
125
-     * database in memory
126
-     *
127
-     * @param array $fixtures
128
-     * @param Doctrine\ORM\Mapping\Driver\Driver $mappingDriver
129
-     * @return EntityManager
130
-     */
131
-    protected function getMockSqliteEntityManager(array $fixtures, MappingDriver $mappingDriver = null)
132
-    {
133
-        $conn = array(
134
-            'driver' => 'pdo_sqlite',
135
-            'memory' => true,
136
-        );
137
-
138
-        $config = $this->getMockAnnotatedORMConfig($mappingDriver);
139
-        $em = EntityManager::create($conn, $config, $this->getEventManager());
140
-
141
-        $schema = array_map(function($class) use ($em) {
142
-            return $em->getClassMetadata($class);
143
-        }, $fixtures);
144
-
145
-        $schemaTool = new SchemaTool($em);
146
-        $schemaTool->dropSchema(array());
147
-        $schemaTool->createSchema($schema);
148
-        return $em;
149
-    }
150
-
151
-    /**
152
-     * EntityManager mock object with
153
-     * annotation mapping driver
154
-     *
155
-     * @param Doctrine\ORM\Mapping\Driver\Driver $mappingDriver
156
-     * @return EntityManager
157
-     */
158
-    protected function getMockMappedEntityManager(MappingDriver $mappingDriver = null)
159
-    {
160
-        $driver = $this->getMock('Doctrine\DBAL\Driver');
161
-        $driver->expects($this->once())
162
-            ->method('getDatabasePlatform')
163
-            ->will($this->returnValue($this->getMock('Doctrine\DBAL\Platforms\MySqlPlatform')));
164
-
165
-        $conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(array(), $driver));
166
-        $conn->expects($this->once())
167
-            ->method('getEventManager')
168
-            ->will($this->returnValue($this->getEventManager()));
169
-
170
-        $config = $this->getMockAnnotatedORMConfig($mappingDriver);
171
-        $em = EntityManager::create($conn, $config);
172
-        return $em;
173
-    }
174
-
175
-    /**
176
-     * Creates default mapping driver
177
-     *
178
-     * @return \Doctrine\ORM\Mapping\Driver\Driver
179
-     */
180
-    protected function getDefaultORMMetadataDriverImplementation()
181
-    {
182
-        return new AnnotationDriverORM($_ENV['annotation_reader']);
183
-    }
184
-
185
-    /**
186
-     * Creates default mapping driver
187
-     *
188
-     * @return \Doctrine\ODM\MongoDB\Mapping\Driver\Driver
189
-     */
190
-    protected function getDefaultMongoODMMetadataDriverImplementation()
191
-    {
192
-        return new AnnotationDriverODM($_ENV['annotation_reader']);
193
-    }
194
-
195
-    /**
196
-     * Build event manager
197
-     *
198
-     * @return EventManager
199
-     */
200
-    private function getEventManager()
201
-    {
202
-        if (null === $this->evm) {
203
-            $this->evm = new EventManager;
204
-            $this->evm->addEventSubscriber(new TreeListener);
205
-            $this->evm->addEventSubscriber(new SluggableListener);
206
-            $this->evm->addEventSubscriber(new LoggableListener);
207
-            $this->evm->addEventSubscriber(new TranslatableListener);
208
-            $this->evm->addEventSubscriber(new TimestampableListener);
209
-        }
210
-
211
-        return $this->evm;
212
-    }
213
-
214
-    /**
215
-     * Get annotation mapping configuration
216
-     *
217
-     * @param string $dbName
218
-     * @param Doctrine\ODM\MongoDB\Mapping\Driver\Driver $mappingDriver
219
-     * @return Doctrine\ORM\Configuration
220
-     */
221
-    private function getMockAnnotatedODMMongoDBConfig($dbName, MappingDriver $mappingDriver = null)
222
-    {
223
-        $config = $this->getMock('Doctrine\\ODM\\MongoDB\\Configuration');
224
-        $config->expects($this->once())
225
-            ->method('getProxyDir')
226
-            ->will($this->returnValue(__DIR__.'/../../temp'));
227
-
228
-        $config->expects($this->once())
229
-            ->method('getProxyNamespace')
230
-            ->will($this->returnValue('Proxy'));
231
-
232
-        $config->expects($this->once())
233
-            ->method('getHydratorDir')
234
-            ->will($this->returnValue(__DIR__.'/../../temp'));
235
-
236
-        $config->expects($this->once())
237
-            ->method('getHydratorNamespace')
238
-            ->will($this->returnValue('Hydrator'));
239
-
240
-        $config->expects($this->any())
241
-            ->method('getDefaultDB')
242
-            ->will($this->returnValue($dbName));
243
-
244
-        $config->expects($this->once())
245
-            ->method('getAutoGenerateProxyClasses')
246
-            ->will($this->returnValue(true));
247
-
248
-        $config->expects($this->once())
249
-            ->method('getAutoGenerateHydratorClasses')
250
-            ->will($this->returnValue(true));
251
-
252
-        $config->expects($this->once())
253
-            ->method('getClassMetadataFactoryName')
254
-            ->will($this->returnValue('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory'));
255
-
256
-        $config
257
-            ->expects($this->any())
258
-            ->method('getMongoCmd')
259
-            ->will($this->returnValue('$'))
260
-        ;
261
-
262
-        $config
263
-            ->expects($this->any())
264
-            ->method('getDefaultCommitOptions')
265
-            ->will($this->returnValue(array('safe' => true)))
266
-        ;
267
-
268
-        if (null === $mappingDriver) {
269
-            $mappingDriver = $this->getDefaultMongoODMMetadataDriverImplementation();
270
-        }
271
-
272
-        $config->expects($this->any())
273
-            ->method('getMetadataDriverImpl')
274
-            ->will($this->returnValue($mappingDriver));
275
-
276
-        return $config;
277
-    }
278
-
279
-    /**
280
-     * Get annotation mapping configuration for ORM
281
-     *
282
-     * @param Doctrine\ORM\Mapping\Driver\Driver $mappingDriver
283
-     * @return Doctrine\ORM\Configuration
284
-     */
285
-    private function getMockAnnotatedORMConfig(MappingDriver $mappingDriver = null)
286
-    {
287
-        $config = $this->getMock('Doctrine\ORM\Configuration');
288
-        $config->expects($this->once())
289
-            ->method('getProxyDir')
290
-            ->will($this->returnValue(__DIR__.'/../../temp'));
291
-
292
-        $config->expects($this->once())
293
-            ->method('getProxyNamespace')
294
-            ->will($this->returnValue('Proxy'));
295
-
296
-        $config->expects($this->once())
297
-            ->method('getAutoGenerateProxyClasses')
298
-            ->will($this->returnValue(true));
299
-
300
-        $config->expects($this->once())
301
-            ->method('getClassMetadataFactoryName')
302
-            ->will($this->returnValue('Doctrine\\ORM\\Mapping\\ClassMetadataFactory'));
303
-
304
-        $config
305
-            ->expects($this->any())
306
-            ->method('getDefaultRepositoryClassName')
307
-            ->will($this->returnValue('Doctrine\\ORM\\EntityRepository'))
308
-        ;
309
-
310
-        $config
311
-            ->expects($this->any())
312
-            ->method('getQuoteStrategy')
313
-            ->will($this->returnValue(new DefaultQuoteStrategy()))
314
-        ;
315
-
316
-        $config
317
-            ->expects($this->any())
318
-            ->method('getNamingStrategy')
319
-            ->will($this->returnValue(new DefaultNamingStrategy()))
320
-        ;
321
-        if (null === $mappingDriver) {
322
-            $mappingDriver = $this->getDefaultORMMetadataDriverImplementation();
323
-        }
324
-
325
-        $config->expects($this->any())
326
-            ->method('getMetadataDriverImpl')
327
-            ->will($this->returnValue($mappingDriver));
328
-
329
-        return $config;
330
-    }
331
-}

+ 0 - 108
vendor/gedmo/doctrine-extensions/tests/Gedmo/Tree/Fixture/MPFeaturesCategory.php View File

@@ -1,108 +0,0 @@
1
-<?php
2
-
3
-namespace Tree\Fixture;
4
-
5
-use Gedmo\Tree\Node as NodeInterface;
6
-use Gedmo\Mapping\Annotation as Gedmo;
7
-use Doctrine\ORM\Mapping as ORM;
8
-
9
-/**
10
- * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\MaterializedPathRepository")
11
- * @Gedmo\Tree(type="materializedPath")
12
- */
13
-class MPFeaturesCategory
14
-{
15
-    /**
16
-     * @ORM\Column(name="id", type="integer")
17
-     * @ORM\Id
18
-     * @ORM\GeneratedValue
19
-     */
20
-    private $id;
21
-
22
-    /**
23
-     * @Gedmo\TreePath(appendId=false, startsWithSeparator=true, endsWithSeparator=false)
24
-     * @ORM\Column(name="path", type="string", length=3000, nullable=true)
25
-     */
26
-    private $path;
27
-
28
-    /**
29
-     * @Gedmo\TreePathHash
30
-     * @ORM\Column(name="pathhash", type="string", length=32, nullable=true)
31
-     */
32
-    private $pathHash;
33
-
34
-    /**
35
-     * @Gedmo\TreePathSource
36
-     * @ORM\Column(name="title", type="string", length=64)
37
-     */
38
-    private $title;
39
-
40
-    /**
41
-     * @Gedmo\TreeParent
42
-     * @ORM\ManyToOne(targetEntity="MPFeaturesCategory", inversedBy="children")
43
-     * @ORM\JoinColumns({
44
-     *   @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
45
-     * })
46
-     */
47
-    private $parentId;
48
-
49
-    /**
50
-     * @Gedmo\TreeLevel
51
-     * @ORM\Column(name="lvl", type="integer", nullable=true)
52
-     */
53
-    private $level;
54
-
55
-    /**
56
-     * @ORM\OneToMany(targetEntity="MPFeaturesCategory", mappedBy="parent")
57
-     */
58
-    private $children;
59
-
60
-    /**
61
-     * @ORM\OneToMany(targetEntity="Article", mappedBy="category")
62
-     */
63
-    private $comments;
64
-
65
-    public function getId()
66
-    {
67
-        return $this->id;
68
-    }
69
-
70
-    public function setTitle($title)
71
-    {
72
-        $this->title = $title;
73
-    }
74
-
75
-    public function getTitle()
76
-    {
77
-        return $this->title;
78
-    }
79
-
80
-    public function setParent(MPFeaturesCategory $parent = null)
81
-    {
82
-        $this->parentId = $parent;
83
-    }
84
-
85
-    public function getParent()
86
-    {
87
-        return $this->parentId;
88
-    }
89
-
90
-    public function setPath($path)
91
-    {
92
-        $this->path = $path;
93
-    }
94
-
95
-    public function getPath()
96
-    {
97
-        return $this->path;
98
-    }
99
-
100
-    public function getLevel()
101
-    {
102
-        return $this->level;
103
-    }
104
-
105
-    public function getPathHash(){
106
-        return $this->pathHash;
107
-    }
108
-}

+ 0 - 109
vendor/gedmo/doctrine-extensions/tests/Gedmo/Tree/MaterializedPathORMFeaturesTest.php View File

@@ -1,109 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Tree;
4
-
5
-use Doctrine\Common\EventManager;
6
-use Tool\BaseTestCaseORM;
7
-
8
-/**
9
- * These are tests for Tree behavior
10
- *
11
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
12
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
13
- * @package Gedmo.Tree
14
- * @link http://www.gediminasm.org
15
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16
- */
17
-class MaterializedPathORMFeaturesTest extends BaseTestCaseORM
18
-{
19
-    const CATEGORY = "Tree\\Fixture\\MPFeaturesCategory";
20
-
21
-    protected $config;
22
-    protected $listener;
23
-
24
-    protected function setUp()
25
-    {
26
-        parent::setUp();
27
-
28
-        $this->listener = new TreeListener;
29
-
30
-        $evm = new EventManager;
31
-        $evm->addEventSubscriber($this->listener);
32
-
33
-        $this->getMockSqliteEntityManager($evm);
34
-
35
-        $meta = $this->em->getClassMetadata(self::CATEGORY);
36
-        $this->config = $this->listener->getConfiguration($this->em, $meta->name);
37
-    }
38
-
39
-    /**
40
-     * @test
41
-     */
42
-    function checkPathsAndHash()
43
-    {
44
-        $category = $this->createCategory();
45
-        $category->setTitle('1');
46
-        $category2 = $this->createCategory();
47
-        $category2->setTitle('2');
48
-        $category3 = $this->createCategory();
49
-        $category3->setTitle('3');
50
-        $category4 = $this->createCategory();
51
-        $category4->setTitle('4');
52
-
53
-        $category2->setParent($category);
54
-        $category3->setParent($category2);
55
-
56
-        $this->em->persist($category4);
57
-        $this->em->persist($category3);
58
-        $this->em->persist($category2);
59
-        $this->em->persist($category);
60
-        $this->em->flush();
61
-
62
-        $this->em->refresh($category);
63
-        $this->em->refresh($category2);
64
-        $this->em->refresh($category3);
65
-        $this->em->refresh($category4);
66
-
67
-        $this->assertEquals($this->generatePath(array('1' => $category->getId())), $category->getPath());
68
-        $this->assertEquals($this->generatePath(array('1' => $category->getId(), '2' => $category2->getId())), $category2->getPath());
69
-        $this->assertEquals($this->generatePath(array('1' => $category->getId(), '2' => $category2->getId(), '3' => $category3->getId())), $category3->getPath());
70
-        $this->assertEquals($this->generatePath(array('4' => $category4->getId())), $category4->getPath());
71
-
72
-        $this->assertEquals($this->generatePathHash(array('1' => $category->getId())), $category->getPathHash());
73
-        $this->assertEquals($this->generatePathHash(array('1' => $category->getId(), '2' => $category2->getId())), $category2->getPathHash());
74
-        $this->assertEquals($this->generatePathHash(array('1' => $category->getId(), '2' => $category2->getId(), '3' => $category3->getId())), $category3->getPathHash());
75
-        $this->assertEquals($this->generatePathHash(array('4' => $category4->getId())), $category4->getPathHash());
76
-    }
77
-
78
-
79
-
80
-
81
-    public function createCategory()
82
-    {
83
-        $class = self::CATEGORY;
84
-        return new $class;
85
-    }
86
-
87
-    protected function getUsedEntityFixtures()
88
-    {
89
-        return array(
90
-            self::CATEGORY
91
-        );
92
-    }
93
-
94
-    public function generatePath(array $sources)
95
-    {
96
-        $path = '';
97
-        foreach ($sources as $p => $id) {
98
-            $path .= $this->config['path_separator'] . $p;
99
-        }
100
-
101
-        return $path;
102
-    }
103
-
104
-    public function generatePathHash(array $sources)
105
-    {
106
-
107
-        return md5($this->generatePath($sources));
108
-    }
109
-}

+ 0 - 27
vendor/gedmo/doctrine-extensions/tests/Gedmo/Uploadable/FilenameGenerator/FilenameGeneratorAlphanumericTest.php View File

@@ -1,27 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable;
4
-
5
-use Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorAlphanumeric;
6
-
7
-/**
8
- * These are tests for FilenameGeneratorAlphanumeric class
9
- *
10
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
11
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
12
- * @package Gedmo.Uploadable.FilenameGenerator
13
- * @link http://www.gediminasm.org
14
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
15
- */
16
-class FilenameGeneratorAlphanumericTest extends \PHPUnit_Framework_TestCase
17
-{
18
-    public function testGenerator()
19
-    {
20
-        $generator = new FilenameGeneratorAlphanumeric();
21
-
22
-        $filename = 'MegaName_For_A_###$$$File$$$###';
23
-        $extension = '.exe';
24
-
25
-        $this->assertEquals('meganame-for-a-file-.exe', $generator->generate($filename, $extension));
26
-    }
27
-}

+ 0 - 698
vendor/gedmo/doctrine-extensions/tests/Gedmo/Uploadable/UploadableEntityTest.php View File

@@ -1,698 +0,0 @@
1
-<?php
2
-
3
-namespace Gedmo\Uploadable;
4
-
5
-use Tool\BaseTestCaseORM,
6
-    Doctrine\Common\EventManager,
7
-    Doctrine\Common\Util\Debug,
8
-    Uploadable\Fixture\Entity\Image,
9
-    Uploadable\Fixture\Entity\Article,
10
-    Uploadable\Fixture\Entity\File,
11
-    Uploadable\Fixture\Entity\FileWithoutPath,
12
-    Uploadable\Fixture\Entity\FileWithSha1Name,
13
-    Uploadable\Fixture\Entity\FileWithAlphanumericName,
14
-    Uploadable\Fixture\Entity\FileWithCustomFilenameGenerator,
15
-    Uploadable\Fixture\Entity\FileAppendNumber,
16
-    Uploadable\Fixture\Entity\FileWithMaxSize,
17
-    Uploadable\Fixture\Entity\FileWithAllowedTypes,
18
-    Uploadable\Fixture\Entity\FileWithDisallowedTypes,
19
-    Gedmo\Uploadable\Stub\UploadableListenerStub,
20
-    Gedmo\Uploadable\Stub\MimeTypeGuesserStub,
21
-    Gedmo\Uploadable\FileInfo\FileInfoArray;
22
-
23
-/**
24
- * These are tests for Uploadable behavior
25
- *
26
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
27
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
28
- * @package Gedmo.Uploadable
29
- * @link http://www.gediminasm.org
30
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
31
- */
32
-class UploadableEntityTest extends BaseTestCaseORM
33
-{
34
-    const IMAGE_CLASS = 'Uploadable\Fixture\Entity\Image';
35
-    const ARTICLE_CLASS = 'Uploadable\Fixture\Entity\Article';
36
-    const FILE_CLASS = 'Uploadable\Fixture\Entity\File';
37
-    const FILE_APPEND_NUMBER_CLASS = 'Uploadable\Fixture\Entity\FileAppendNumber';
38
-    const FILE_WITHOUT_PATH_CLASS = 'Uploadable\Fixture\Entity\FileWithoutPath';
39
-    const FILE_WITH_SHA1_NAME_CLASS = 'Uploadable\Fixture\Entity\FileWithSha1Name';
40
-    const FILE_WITH_ALPHANUMERIC_NAME_CLASS = 'Uploadable\Fixture\Entity\FileWithAlphanumericName';
41
-    const FILE_WITH_CUSTOM_FILENAME_GENERATOR_CLASS = 'Uploadable\Fixture\Entity\FileWithCustomFilenameGenerator';
42
-    const FILE_WITH_MAX_SIZE_CLASS = 'Uploadable\Fixture\Entity\FileWithMaxSize';
43
-    const FILE_WITH_ALLOWED_TYPES_CLASS = 'Uploadable\Fixture\Entity\FileWithAllowedTypes';
44
-    const FILE_WITH_DISALLOWED_TYPES_CLASS = 'Uploadable\Fixture\Entity\FileWithDisallowedTypes';
45
-
46
-    private $listener;
47
-    private $testFile;
48
-    private $testFile2;
49
-    private $testFile3;
50
-    private $testFileWithoutExt;
51
-    private $testFileWithSpaces;
52
-    private $destinationTestDir;
53
-    private $destinationTestFile;
54
-    private $destinationTestFile2;
55
-    private $destinationTestFile3;
56
-    private $destinationTestFileWithoutExt;
57
-    private $destinationTestFileWithspaces;
58
-    private $testFilename;
59
-    private $testFilename2;
60
-    private $testFilename3;
61
-    private $testFilenameWithoutExt;
62
-    private $testFilenameWithSpaces;
63
-    private $testFileSize;
64
-    private $testFileMimeType;
65
-
66
-    protected function setUp()
67
-    {
68
-        parent::setUp();
69
-
70
-        $evm = new EventManager;
71
-        $this->listener = new UploadableListenerStub();
72
-        $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub('text/plain'));
73
-
74
-        $evm->addEventSubscriber($this->listener);
75
-        $config = $this->getMockAnnotatedConfig();
76
-        $this->em = $this->getMockSqliteEntityManager($evm, $config);
77
-        $this->testFile = __DIR__.'/../../data/test.txt';
78
-        $this->testFile2 = __DIR__.'/../../data/test2.txt';
79
-        $this->testFile3 = __DIR__.'/../../data/test_3.txt';
80
-        $this->testFileWithoutExt = __DIR__.'/../../data/test4';
81
-        $this->testFileWithSpaces = __DIR__.'/../../data/test with spaces.txt';
82
-        $this->destinationTestDir = __DIR__.'/../../temp/uploadable';
83
-        $this->destinationTestFile = $this->destinationTestDir.'/test.txt';
84
-        $this->destinationTestFile2 = $this->destinationTestDir.'/test2.txt';
85
-        $this->destinationTestFile3 = $this->destinationTestDir.'/test_3.txt';
86
-        $this->destinationTestFileWithoutExt = $this->destinationTestDir.'/test4';
87
-        $this->destinationTestFileWithSpaces = $this->destinationTestDir.'/test with spaces';
88
-        $this->testFilename = substr($this->testFile, strrpos($this->testFile, '/') + 1);
89
-        $this->testFilename2 = substr($this->testFile2, strrpos($this->testFile2, '/') + 1);
90
-        $this->testFilename3 = substr($this->testFile3, strrpos($this->testFile3, '/') + 1);
91
-        $this->testFilenameWithoutExt = substr($this->testFileWithoutExt, strrpos($this->testFileWithoutExt, '/') + 1);
92
-        $this->testFilenameWithSpaces= substr($this->testFileWithSpaces, strrpos($this->testFileWithSpaces, '/') + 1);
93
-        $this->testFileSize = 4;
94
-        $this->testFileMimeType = 'text/plain';
95
-
96
-        $this->clearFilesAndDirectories();
97
-
98
-        if (!is_dir($this->destinationTestDir)) {
99
-            mkdir($this->destinationTestDir);
100
-        };
101
-    }
102
-
103
-    public function tearDown()
104
-    {
105
-        $this->clearFilesAndDirectories();
106
-    }
107
-
108
-    public function testUploadableEntity()
109
-    {
110
-        // INSERTION of an Uploadable Entity
111
-
112
-        // If there was no uploaded file, we do nothing
113
-        $image = new Image();
114
-        $image->setTitle('123');
115
-
116
-        $this->em->persist($image);
117
-        $this->em->flush();
118
-
119
-        $this->assertNull($image->getFilePath());
120
-
121
-        // If there is an uploaded file, we process it
122
-        $fileInfo = $this->generateUploadedFile();
123
-
124
-        $image2 = new Image();
125
-        $image2->setTitle('456');
126
-        $this->listener->addEntityFileInfo($image2, $fileInfo);
127
-
128
-        $this->em->persist($image2);
129
-        $this->em->flush();
130
-
131
-        $this->em->refresh($image2);
132
-
133
-        // We need to set this again because of the recent refresh
134
-        $firstFile = $image2->getFilePath();
135
-
136
-        $this->assertPathEquals($image2->getPath().'/'.$fileInfo['name'], $image2->getFilePath());
137
-        $this->assertTrue(is_file($firstFile));
138
-        $this->assertEquals($fileInfo['size'], $image2->getSize());
139
-        $this->assertEquals($fileInfo['type'], $image2->getMime());
140
-
141
-        // UPDATE of an Uploadable Entity
142
-
143
-        // We change the "uploaded" file
144
-        $fileInfo['tmp_name'] = $this->testFile2;
145
-        $fileInfo['name'] = $this->testFilename2;
146
-
147
-        // We use a FileInfoInterface instance here
148
-        $this->listener->addEntityFileInfo($image2, new FileInfoArray($fileInfo));
149
-
150
-        $this->em->flush();
151
-
152
-        $this->em->refresh($image2);
153
-
154
-        $lastFile = $image2->getFilePath();
155
-
156
-        $this->assertPathEquals($image2->getPath().'/'.$fileInfo['name'], $image2->getFilePath());
157
-        $this->assertTrue(is_file($lastFile));
158
-
159
-        // First file should be removed on update
160
-        $this->assertFalse(is_file($firstFile));
161
-
162
-        // REMOVAL of an Uploadable Entity
163
-        $this->em->remove($image2);
164
-        $this->em->flush();
165
-
166
-        $this->assertFalse(is_file($lastFile));
167
-    }
168
-
169
-    public function testEntityWithUploadableEntities()
170
-    {
171
-        $artRepo = $this->em->getRepository(self::ARTICLE_CLASS);
172
-        $article = new Article();
173
-        $article->setTitle('Test');
174
-
175
-        $file1 = new File();
176
-        $file2 = new File();
177
-        $file3 = new File();
178
-
179
-        $article->addFile($file1);
180
-        $article->addFile($file2);
181
-        $article->addFile($file3);
182
-
183
-        $filesArrayIndex = 'file';
184
-
185
-        $fileInfo = $this->generateUploadedFile($filesArrayIndex);
186
-        $fileInfo2 = $this->generateUploadedFile($filesArrayIndex);
187
-        $fileInfo3 = $this->generateUploadedFile($filesArrayIndex);
188
-
189
-        $this->listener->addEntityFileInfo($file1, $fileInfo);
190
-        $this->listener->addEntityFileInfo($file2, $fileInfo2);
191
-        $this->listener->addEntityFileInfo($file3, $fileInfo3);
192
-
193
-        $this->em->persist($article);
194
-
195
-        $this->em->flush();
196
-
197
-        $art = $artRepo->findOneByTitle('Test');
198
-        $files = $art->getFiles();
199
-        $file1Path = $file1->getPath().'/'.$fileInfo['name'];
200
-        $file2Path = $file2->getPath().'/'.$fileInfo['name'];
201
-        $file3Path = $file3->getPath().'/'.$fileInfo['name'];
202
-
203
-        $this->assertPathEquals($file1Path, $files[0]->getFilePath());
204
-        $this->assertPathEquals($file2Path, $files[1]->getFilePath());
205
-        $this->assertPathEquals($file3Path, $files[2]->getFilePath());
206
-    }
207
-
208
-    /**
209
-     * @expectedException Gedmo\Exception\UploadableNoPathDefinedException
210
-     */
211
-    public function testNoPathDefinedOnEntityOrListenerThrowsException()
212
-    {
213
-        $file = new FileWithoutPath();
214
-
215
-        $fileInfo = $this->generateUploadedFile();
216
-
217
-        $this->listener->addEntityFileInfo($file, $fileInfo);
218
-
219
-        $this->em->persist($file);
220
-        $this->em->flush();
221
-    }
222
-
223
-    public function testNoPathDefinedOnEntityButDefinedOnListenerUsesDefaultPath()
224
-    {
225
-        // We set the default path on the listener
226
-        $this->listener->setDefaultPath($this->destinationTestDir);
227
-
228
-        $file = new FileWithoutPath();
229
-        $fileInfo = $this->generateUploadedFile();
230
-
231
-        $this->listener->addEntityFileInfo($file, $fileInfo);
232
-
233
-        $this->em->persist($file);
234
-        $this->em->flush();
235
-
236
-        $this->em->refresh($file);
237
-
238
-        $this->assertPathEquals($this->destinationTestFile, $file->getFilePath());
239
-    }
240
-
241
-    public function testCallbackIsCalledIfItsSetOnEntity()
242
-    {
243
-        $file = new File();
244
-        $fileInfo = $this->generateUploadedFile();
245
-
246
-        $this->listener->addEntityFileInfo($file, $fileInfo);
247
-
248
-        $this->em->persist($file);
249
-        $this->em->flush();
250
-
251
-        $this->assertTrue($file->callbackWasCalled);
252
-    }
253
-
254
-    /**
255
-     * @dataProvider uploadExceptionsProvider
256
-     */
257
-    public function testUploadExceptions($error, $exceptionClass)
258
-    {
259
-        $this->setExpectedException($exceptionClass);
260
-
261
-        $file = new File();
262
-        $fileInfo = $this->generateUploadedFile();
263
-        $fileInfo['error'] = $error;
264
-
265
-        $this->listener->addEntityFileInfo($file, $fileInfo);
266
-
267
-        $this->em->persist($file);
268
-        $this->em->flush();
269
-    }
270
-
271
-    public function testSettingAnotherDefaultFileInfoClass()
272
-    {
273
-        $fileInfoStubClass = 'Gedmo\Uploadable\Stub\FileInfoStub';
274
-
275
-        $this->listener->setDefaultFileInfoClass($fileInfoStubClass);
276
-
277
-        $file = new File();
278
-        $fileInfo = $this->generateUploadedFile();
279
-
280
-        $this->listener->addEntityFileInfo($file, $fileInfo);
281
-        $fileInfo = $this->listener->getEntityFileInfo($file);
282
-
283
-        $this->assertInstanceOf($fileInfoStubClass, $fileInfo);
284
-    }
285
-
286
-    public function testFileWithFilenameSha1Generator()
287
-    {
288
-        $file = new FileWithSha1Name();
289
-        $fileInfo = $this->generateUploadedFile();
290
-
291
-        $this->listener->addEntityFileInfo($file, $fileInfo);
292
-
293
-        $this->em->persist($file);
294
-        $this->em->flush();
295
-
296
-        $this->em->refresh($file);
297
-
298
-        $sha1String = substr($file->getFilePath(), strrpos($file->getFilePath(), '/') + 1);
299
-        $sha1String = str_replace('.txt', '', $sha1String);
300
-
301
-        $this->assertRegExp('/[a-z0-9]{40}/', $sha1String);
302
-    }
303
-
304
-    public function testFileWithFilenameAlphanumericGenerator()
305
-    {
306
-        $file = new FileWithAlphanumericName();
307
-        $fileInfo = $this->generateUploadedFile('image', $this->testFile3, $this->testFilename3);
308
-
309
-        $this->listener->addEntityFileInfo($file, $fileInfo);
310
-
311
-        $this->em->persist($file);
312
-        $this->em->flush();
313
-
314
-        $this->em->refresh($file);
315
-
316
-        $filename = substr($file->getFilePath(), strrpos($file->getFilePath(), '/') + 1);
317
-
318
-        $this->assertEquals('test-3.txt', $filename);
319
-    }
320
-
321
-    public function testFileWithCustomFilenameGenerator()
322
-    {
323
-        $file = new FileWithCustomFilenameGenerator();
324
-        $fileInfo = $this->generateUploadedFile();
325
-
326
-        $this->listener->addEntityFileInfo($file, $fileInfo);
327
-
328
-        $this->em->persist($file);
329
-        $this->em->flush();
330
-
331
-        $this->em->refresh($file);
332
-
333
-        $filename = substr($file->getFilePath(), strrpos($file->getFilePath(), '/') + 1);
334
-
335
-        $this->assertEquals('123.txt', $filename);
336
-    }
337
-
338
-    public function testUploadFileWithoutExtension()
339
-    {
340
-        $file = new File();
341
-        $fileInfo = $this->generateUploadedFile('image', $this->testFileWithoutExt, $this->testFilenameWithoutExt);
342
-
343
-        $this->listener->addEntityFileInfo($file, $fileInfo);
344
-
345
-        $this->em->persist($file);
346
-        $this->em->flush();
347
-
348
-        $this->em->refresh($file);
349
-
350
-        $filePath = $file->getPath().'/'.$fileInfo['name'];
351
-
352
-        $this->assertPathEquals($filePath, $file->getFilePath());
353
-    }
354
-
355
-    /**
356
-     * @expectedException Gedmo\Exception\UploadableFileAlreadyExistsException
357
-     */
358
-    public function testFileAlreadyExistsException()
359
-    {
360
-        $file = new Image();
361
-        $file->setTitle('test');
362
-        $fileInfo = $this->generateUploadedFile('image', $this->testFileWithoutExt, $this->testFilenameWithoutExt);
363
-
364
-        $this->listener->addEntityFileInfo($file, $fileInfo);
365
-
366
-        $this->em->persist($file);
367
-        $this->em->flush();
368
-
369
-        $this->listener->addEntityFileInfo($file, $fileInfo);
370
-
371
-        $this->em->flush();
372
-    }
373
-
374
-    public function test_removeFile_ifItsNotAFileThenReturnFalse()
375
-    {
376
-        $this->assertFalse($this->listener->removeFile('non_existent_file'));
377
-    }
378
-
379
-    public function test_moveFile_usingAppendNumberOptionAppendsNumberToFilenameIfItAlreadyExists()
380
-    {
381
-        $file = new FileAppendNumber();
382
-        $file2 = new FileAppendNumber();
383
-
384
-        $file->setTitle('test');
385
-        $file2->setTitle('test2');
386
-
387
-        $fileInfo = $this->generateUploadedFile();
388
-
389
-        $this->listener->addEntityFileInfo($file, $fileInfo);
390
-
391
-        $this->em->persist($file);
392
-        $this->em->flush();
393
-
394
-        $this->listener->addEntityFileInfo($file2, $fileInfo);
395
-
396
-        $this->em->persist($file2);
397
-        $this->em->flush();
398
-
399
-        $this->em->refresh($file2);
400
-
401
-        $filename = substr($file2->getFilePath(), strrpos($file2->getFilePath(), '/') + 1);
402
-
403
-        $this->assertEquals('test-2.txt', $filename);
404
-    }
405
-
406
-    /**
407
-     * @expectedException Gedmo\Exception\UploadableUploadException
408
-     */
409
-    public function test_moveFile_ifUploadedFileCantBeMovedThrowException()
410
-    {
411
-        $this->listener->returnFalseOnMoveUploadedFile = true;
412
-
413
-        $file = new Image();
414
-        $file->setTitle('test');
415
-        $fileInfo = $this->generateUploadedFile();
416
-
417
-        $this->listener->addEntityFileInfo($file, $fileInfo);
418
-
419
-        $this->em->persist($file);
420
-        $this->em->flush();
421
-    }
422
-
423
-    /**
424
-     * @expectedException RuntimeException
425
-     */
426
-    public function test_addEntityFileInfo_ifFileInfoIsNotValidThrowException()
427
-    {
428
-        $this->listener->addEntityFileInfo(new Image, 'invalidFileInfo');
429
-    }
430
-
431
-    /**
432
-     * @expectedException RuntimeException
433
-     */
434
-    public function test_getEntityFileInfo_ifTheresNoFileInfoForEntityThrowException()
435
-    {
436
-        $this->listener->getEntityFileInfo(new Image);
437
-    }
438
-
439
-    /**
440
-     * @expectedException Gedmo\Exception\UploadableMaxSizeException
441
-     */
442
-    public function test_fileExceedingMaximumAllowedSizeThrowsException()
443
-    {
444
-        // We set the default path on the listener
445
-        $this->listener->setDefaultPath($this->destinationTestDir);
446
-
447
-        $file = new FileWithMaxSize();
448
-        $fileInfo = $this->generateUploadedFile();
449
-
450
-        $this->listener->addEntityFileInfo($file, $fileInfo);
451
-
452
-        $this->em->persist($file);
453
-        $this->em->flush();
454
-    }
455
-
456
-    public function test_fileNotExceedingMaximumAllowedSizeDoesntThrowException()
457
-    {
458
-        // We set the default path on the listener
459
-        $this->listener->setDefaultPath($this->destinationTestDir);
460
-
461
-        $file = new FileWithMaxSize();
462
-        $size = 0.0001;
463
-        $fileInfo = $this->generateUploadedFile('image', false, false, array('size' => $size));
464
-
465
-        $this->listener->addEntityFileInfo($file, $fileInfo);
466
-
467
-        $this->em->persist($file);
468
-        $this->em->flush();
469
-
470
-        $this->em->refresh($file);
471
-
472
-        $this->assertEquals($size, $file->getFileSize());
473
-    }
474
-
475
-    /**
476
-     * @expectedException Gedmo\Exception\UploadableCouldntGuessMimeTypeException
477
-     */
478
-    public function test_ifMimeTypeGuesserCantResolveTypeThrowException()
479
-    {
480
-        // We set the default path on the listener
481
-        $this->listener->setDefaultPath($this->destinationTestDir);
482
-        $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub(null));
483
-
484
-        $file = new FileWithAllowedTypes();
485
-        $fileInfo = $this->generateUploadedFile();
486
-
487
-        $this->listener->addEntityFileInfo($file, $fileInfo);
488
-
489
-        $this->em->persist($file);
490
-        $this->em->flush();
491
-    }
492
-
493
-    /**
494
-     * @expectedException Gedmo\Exception\UploadableInvalidMimeTypeException
495
-     */
496
-    public function test_allowedTypesOption_ifMimeTypeIsInvalidThrowException()
497
-    {
498
-        // We set the default path on the listener
499
-        $this->listener->setDefaultPath($this->destinationTestDir);
500
-        $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub('text/css'));
501
-
502
-        $file = new FileWithAllowedTypes();
503
-        $fileInfo = $this->generateUploadedFile();
504
-
505
-        $this->listener->addEntityFileInfo($file, $fileInfo);
506
-
507
-        $this->em->persist($file);
508
-        $this->em->flush();
509
-    }
510
-
511
-    public function test_allowedTypesOption_ifMimeTypeIsValidThenDontThrowException()
512
-    {
513
-        // We set the default path on the listener
514
-        $this->listener->setDefaultPath($this->destinationTestDir);
515
-
516
-        $file = new FileWithAllowedTypes();
517
-        $fileInfo = $this->generateUploadedFile();
518
-
519
-        $this->listener->addEntityFileInfo($file, $fileInfo);
520
-
521
-        $this->em->persist($file);
522
-        $this->em->flush();
523
-    }
524
-
525
-    /**
526
-     * @expectedException Gedmo\Exception\UploadableInvalidMimeTypeException
527
-     */
528
-    public function test_disallowedTypesOption_ifMimeTypeIsInvalidThrowException()
529
-    {
530
-        // We set the default path on the listener
531
-        $this->listener->setDefaultPath($this->destinationTestDir);
532
-        $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub('text/css'));
533
-
534
-        $file = new FileWithDisallowedTypes();
535
-        $fileInfo = $this->generateUploadedFile();
536
-
537
-        $this->listener->addEntityFileInfo($file, $fileInfo);
538
-
539
-        $this->em->persist($file);
540
-        $this->em->flush();
541
-    }
542
-
543
-    public function test_disallowedTypesOption_ifMimeTypeIsValidThenDontThrowException()
544
-    {
545
-        // We set the default path on the listener
546
-        $this->listener->setDefaultPath($this->destinationTestDir);
547
-        $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub('video/jpeg'));
548
-
549
-        $file = new FileWithDisallowedTypes();
550
-        $fileInfo = $this->generateUploadedFile();
551
-
552
-        $this->listener->addEntityFileInfo($file, $fileInfo);
553
-
554
-        $this->em->persist($file);
555
-        $this->em->flush();
556
-    }
557
-
558
-    /**
559
-     * @expectedException Gedmo\Exception\InvalidArgumentException
560
-     * @dataProvider invalidFileInfoClassesProvider
561
-     */
562
-    public function test_setDefaultFileInfoClass_throwExceptionIfInvalidClassArePassed($class)
563
-    {
564
-        $this->listener->setDefaultFileInfoClass($class);
565
-    }
566
-
567
-    public function test_setDefaultFileInfoClass_setClassIfClassIsValid()
568
-    {
569
-        $validClass = 'Gedmo\\Uploadable\\FileInfo\\FileInfoArray';
570
-
571
-        $this->listener->setDefaultFileInfoClass($validClass);
572
-
573
-        $this->assertEquals($validClass, $this->listener->getDefaultFileInfoClass());
574
-    }
575
-
576
-    public function test_useGeneratedFilenameWhenAppendingNumbers()
577
-    {
578
-        // We set the default path on the listener
579
-        $this->listener->setDefaultPath($this->destinationTestDir);
580
-
581
-        $file = new FileWithAlphanumericName();
582
-        $fileInfo = $this->generateUploadedFile('file', $this->testFileWithSpaces, $this->testFilenameWithSpaces);
583
-
584
-        $this->listener->addEntityFileInfo($file, $fileInfo);
585
-
586
-        $this->em->persist($file);
587
-        $this->em->flush();
588
-
589
-        $filePath = $file->getPath().'/'.str_replace(' ', '-', $fileInfo['name']);
590
-
591
-        $this->assertPathEquals($filePath, $file->getFilePath());
592
-
593
-        $file = new FileWithAlphanumericName();
594
-
595
-        $this->listener->addEntityFileInfo($file, $fileInfo);
596
-
597
-        $this->em->persist($file);
598
-        $this->em->flush();
599
-
600
-        $filePath = $file->getPath().'/'.str_replace(' ', '-', str_replace('.txt', '-2.txt', $fileInfo['name']));
601
-
602
-        $this->assertPathEquals($filePath, $file->getFilePath());
603
-    }
604
-
605
-    // Data Providers
606
-    public function invalidFileInfoClassesProvider()
607
-    {
608
-        return array(
609
-            array(''),
610
-            array(false),
611
-            array(null),
612
-            array('FakeFileInfo'),
613
-            array(array()),
614
-            array(new \DateTime())
615
-        );
616
-    }
617
-
618
-    public function uploadExceptionsProvider()
619
-    {
620
-        return array(
621
-            array(1, 'Gedmo\Exception\UploadableIniSizeException'),
622
-            array(2, 'Gedmo\Exception\UploadableFormSizeException'),
623
-            array(3, 'Gedmo\Exception\UploadablePartialException'),
624
-            array(4, 'Gedmo\Exception\UploadableNoFileException'),
625
-            array(6, 'Gedmo\Exception\UploadableNoTmpDirException'),
626
-            array(7, 'Gedmo\Exception\UploadableCantWriteException'),
627
-            array(8, 'Gedmo\Exception\UploadableExtensionException'),
628
-            array(999, 'Gedmo\Exception\UploadableUploadException')
629
-        );
630
-    }
631
-
632
-
633
-
634
-
635
-    // Util
636
-
637
-    private function generateUploadedFile($index = 'image', $filePath = false, $filename = false, array $info = array())
638
-    {
639
-        $defaultInfo = array(
640
-            'tmp_name'          => !$filePath ? $this->testFile : $filePath,
641
-            'name'              => !$filename ? $this->testFilename : $filename,
642
-            'size'              => $this->testFileSize,
643
-            'type'              => $this->testFileMimeType,
644
-            'error'             => 0
645
-        );
646
-
647
-        $info = array_merge($defaultInfo, $info);
648
-
649
-        return $info;
650
-    }
651
-
652
-    protected function getUsedEntityFixtures()
653
-    {
654
-        return array(
655
-            self::IMAGE_CLASS,
656
-            self::ARTICLE_CLASS,
657
-            self::FILE_CLASS,
658
-            self::FILE_WITHOUT_PATH_CLASS,
659
-            self::FILE_APPEND_NUMBER_CLASS,
660
-            self::FILE_WITH_ALPHANUMERIC_NAME_CLASS,
661
-            self::FILE_WITH_SHA1_NAME_CLASS,
662
-            self::FILE_WITH_CUSTOM_FILENAME_GENERATOR_CLASS,
663
-            self::FILE_WITH_MAX_SIZE_CLASS,
664
-            self::FILE_WITH_ALLOWED_TYPES_CLASS,
665
-            self::FILE_WITH_DISALLOWED_TYPES_CLASS
666
-        );
667
-    }
668
-
669
-    private function clearFilesAndDirectories()
670
-    {
671
-        if (is_dir($this->destinationTestDir)) {
672
-            $iter = new \DirectoryIterator($this->destinationTestDir);
673
-
674
-            foreach ($iter as $fileInfo) {
675
-                if (!$fileInfo->isDot()) {
676
-                    @unlink($fileInfo->getPathname());
677
-                }
678
-            }
679
-        }
680
-    }
681
-
682
-    protected function assertPathEquals($expected, $path, $message = '')
683
-    {
684
-        $this->assertEquals($expected, $path, $message);
685
-    }
686
-}
687
-
688
-class FakeFileInfo
689
-{
690
-}
691
-
692
-class FakeFilenameGenerator implements \Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorInterface
693
-{
694
-    public static function generate($filename, $extension, $object = null)
695
-    {
696
-        return '123.txt';
697
-    }
698
-}

+ 0 - 62
vendor/gedmo/doctrine-extensions/tests/bootstrap.php View File

@@ -1,62 +0,0 @@
1
-<?php
2
-
3
-use Doctrine\Common\Annotations\AnnotationRegistry;
4
-use Doctrine\Common\Annotations\AnnotationReader;
5
-use Doctrine\Common\Annotations\CachedReader;
6
-use Doctrine\Common\Cache\ArrayCache;
7
-use Composer\Autoload\ClassLoader;
8
-
9
-/**
10
- * This is bootstrap for phpUnit unit tests,
11
- * use README.md for more details
12
- *
13
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
14
- * @author Christoph Krämer <cevou@gmx.de>
15
- * @package Gedmo.Tests
16
- * @link http://www.gediminasm.org
17
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
18
- */
19
-
20
-define('TESTS_PATH', __DIR__);
21
-define('TESTS_TEMP_DIR', __DIR__ . '/temp');
22
-define('VENDOR_PATH', realpath(__DIR__ . '/../vendor'));
23
-
24
-if (!class_exists('PHPUnit_Framework_TestCase') ||
25
-    version_compare(PHPUnit_Runner_Version::id(), '3.5') < 0
26
-) {
27
-    die('PHPUnit framework is required, at least 3.5 version');
28
-}
29
-
30
-if (!class_exists('PHPUnit_Framework_MockObject_MockBuilder')) {
31
-    die('PHPUnit MockObject plugin is required, at least 1.0.8 version');
32
-}
33
-
34
-/** @var $loader ClassLoader */
35
-$loader = require __DIR__ . '/../vendor/autoload.php';
36
-
37
-$loader->add('Gedmo\\Mapping\\Mock', __DIR__);
38
-$loader->add('Tool', __DIR__ . '/Gedmo');
39
-// fixture namespaces
40
-$loader->add('Translator\\Fixture', __DIR__ . '/Gedmo');
41
-$loader->add('Translatable\\Fixture', __DIR__ . '/Gedmo');
42
-$loader->add('Timestampable\\Fixture', __DIR__ . '/Gedmo');
43
-$loader->add('Blameable\\Fixture', __DIR__.'/Gedmo');
44
-$loader->add('Tree\\Fixture', __DIR__ . '/Gedmo');
45
-$loader->add('Sluggable\\Fixture', __DIR__ . '/Gedmo');
46
-$loader->add('Sortable\\Fixture', __DIR__ . '/Gedmo');
47
-$loader->add('Mapping\\Fixture', __DIR__ . '/Gedmo');
48
-$loader->add('Loggable\\Fixture', __DIR__ . '/Gedmo');
49
-$loader->add('SoftDeleteable\\Fixture', __DIR__ . '/Gedmo');
50
-$loader->add('Uploadable\\Fixture', __DIR__ . '/Gedmo');
51
-$loader->add('Wrapper\\Fixture', __DIR__ . '/Gedmo');
52
-$loader->add('ReferenceIntegrity\\Fixture', __DIR__ . '/Gedmo');
53
-$loader->add('References\\Fixture', __DIR__ . '/Gedmo');
54
-// stubs
55
-$loader->add('Gedmo\\Uploadable\\Stub', __DIR__);
56
-
57
-AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
58
-Gedmo\DoctrineExtensions::registerAnnotations();
59
-
60
-$reader = new AnnotationReader();
61
-$reader = new CachedReader($reader, new ArrayCache());
62
-$_ENV['annotation_reader'] = $reader;

+ 0 - 66
vendor/gedmo/doctrine-extensions/tests/phpunit.xml.dist View File

@@ -1,66 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<phpunit backupGlobals="false"
3
-         backupStaticAttributes="false"
4
-         colors="true"
5
-         convertErrorsToExceptions="true"
6
-         convertNoticesToExceptions="true"
7
-         convertWarningsToExceptions="true"
8
-         processIsolation="false"
9
-         stopOnFailure="false"
10
-         syntaxCheck="false"
11
-         bootstrap="./bootstrap.php"
12
->
13
-    <testsuites>
14
-        <testsuite name="Translatable Extension">
15
-            <directory suffix="Test.php">./Gedmo/Translatable/</directory>
16
-        </testsuite>
17
-        <testsuite name="Sluggable Extension">
18
-            <directory suffix="Test.php">./Gedmo/Sluggable/</directory>
19
-        </testsuite>
20
-        <testsuite name="Sortable Extension">
21
-            <directory suffix="Test.php">./Gedmo/Sortable/</directory>
22
-        </testsuite>
23
-        <testsuite name="Tree Extension">
24
-            <directory suffix="Test.php">./Gedmo/Tree/</directory>
25
-        </testsuite>
26
-        <testsuite name="Timestampable Extension">
27
-            <directory suffix="Test.php">./Gedmo/Timestampable/</directory>
28
-        </testsuite>
29
-        <testsuite name="Blameable Extension">
30
-            <directory suffix="Test.php">./Gedmo/Blameable/</directory>
31
-        </testsuite>
32
-        <testsuite name="Mapping Extension">
33
-            <directory suffix="Test.php">./Gedmo/Mapping/</directory>
34
-        </testsuite>
35
-        <testsuite name="Loggable Extension">
36
-            <directory suffix="Test.php">./Gedmo/Loggable/</directory>
37
-        </testsuite>
38
-        <testsuite name="Sortable Extension">
39
-            <directory suffix="Test.php">./Gedmo/Sortable/</directory>
40
-        </testsuite>
41
-        <testsuite name="Object wrappers">
42
-            <directory suffix="Test.php">./Gedmo/Wrapper/</directory>
43
-        </testsuite>
44
-        <testsuite name="Translator extension">
45
-            <directory suffix="Test.php">./Gedmo/Translator/</directory>
46
-        </testsuite>
47
-        <testsuite name="SoftDeleteable Extension">
48
-            <directory suffix="Test.php">./Gedmo/SoftDeleteable/</directory>
49
-        </testsuite>
50
-        <testsuite name="Uploadable Extension">
51
-            <directory suffix="Test.php">./Gedmo/Uploadable/</directory>
52
-        </testsuite>
53
-        <testsuite name="ReferenceIntegrity Extension">
54
-            <directory suffix="Test.php">./Gedmo/ReferenceIntegrity/</directory>
55
-        </testsuite>
56
-        <testsuite name="References Extension">
57
-            <directory suffix="Test.php">./Gedmo/References/</directory>
58
-        </testsuite>
59
-    </testsuites>
60
-
61
-    <filter>
62
-        <whitelist>
63
-            <directory>../lib</directory>
64
-        </whitelist>
65
-    </filter>
66
-</phpunit>

+ 0 - 87
vendor/jdorn/sql-formatter/README.md View File

@@ -1,87 +0,0 @@
1
-SqlFormatter
2
-=============
3
-
4
-A lightweight php class for formatting sql statements.  Handles automatic
5
-indentation and syntax highlighting.
6
-
7
-History
8
-============
9
-
10
-I found myself having to debug auto-generated SQL statements all the time and
11
-wanted some way to easily output formatted HTML without having to include a 
12
-huge library or copy and paste into online formatters.
13
-
14
-I was originally planning to extract the formatting code from PhpMyAdmin,
15
-but that was 10,000+ lines of code and used global variables.
16
-
17
-I saw that other people had the same problem and used Stack Overflow user 
18
-losif's answer as a starting point.  http://stackoverflow.com/a/3924147
19
-
20
-Usage
21
-============
22
-
23
-The SqlFormatter class has a static method 'format' which takes a SQL string  
24
-as input and returns a formatted HTML block inside a pre tag. 
25
-
26
-Sample usage:
27
-
28
-```php
29
-<?php
30
-require_once('SqlFormatter.php');
31
-
32
-echo SqlFormatter::format("SELECT * FROM MyTable LIMIT 10");
33
-```
34
-
35
-Sample output:
36
-
37
-![](http://github.com/jdorn/sql-formatter/raw/master/examples/SqlFormatterExample.png)
38
-
39
-Syntax Highlighting Only
40
--------------------------
41
-
42
-There is also a static method 'highlight' that only does syntax highlighting 
43
-and preserves all original whitespace.
44
-
45
-This is useful for sql that is already well formatted and just needs to be a little
46
-easier to read.
47
-
48
-```php
49
-<?php
50
-echo SqlFormatter::highlight("SELECT * FROM MyTable LIMIT 10");
51
-```
52
-
53
-Split SQL String into Queries
54
---------------------------
55
-
56
-Another feature, which is unrelated to formatting, is the ability to break up a SQL string into multiple queries.  
57
-
58
-For Example:
59
-
60
-```sql
61
-DROP TABLE IF EXISTS MyTable;
62
-CREATE TABLE MyTable ( id int );
63
-INSERT INTO MyTable	(id)
64
-	VALUES
65
-	(1),(2),(3),(4);
66
-SELECT * FROM MyTable;
67
-```
68
-
69
-```php
70
-$queries = SqlFormatter::splitQuery($sql);
71
-```
72
-$queries is now an array of the 4 queries without trailing semicolons.
73
-
74
-Why not just use explode(';',$sql) or regular expressions?  The following example sql and others like it
75
-are impossible to split correctly using regular expressions.
76
-
77
-```sql
78
-SELECT ";"; SELECT ";\"; a;";
79
-SELECT ";
80
-    abc";
81
-SELECT a,b #comment;
82
-FROM test;
83
-```
84
-
85
-The splitQuery method will still fail in the following cases:
86
-*    The DELIMITER command can be used to change the delimiter from the default ';' to something else.  
87
-*    The CREATE PROCEDURE command

BIN
vendor/jdorn/sql-formatter/examples/SqlFormatterExample.png View File


+ 0 - 220
vendor/jdorn/sql-formatter/examples/examples.php View File

@@ -1,220 +0,0 @@
1
-<!DOCTYPE html>
2
-<html>
3
-<head>
4
-    <title>SqlFormatter Examples</title>
5
-    <style>
6
-        body {
7
-            font-family: arial;
8
-        }
9
-
10
-        table, td, th {
11
-            border: 1px solid #aaa;
12
-        }
13
-
14
-        table {
15
-            border-width: 1px 1px 0 0;
16
-            border-spacing: 0;
17
-        }
18
-
19
-        td, th {
20
-            border-width: 0 0 1px 1px;
21
-            padding: 5px 10px;
22
-            vertical-align: top;
23
-        }
24
-
25
-        pre {
26
-            padding: 0;
27
-            margin: 0;
28
-        }
29
-    </style>
30
-</head>
31
-<body>
32
-<?php
33
-
34
-require_once('../lib/SqlFormatter.php');
35
-
36
-// Example statements for formatting and highlighting
37
-$statements = array(
38
-    "SELECT * FROM MyTable WHERE id = 46",
39
-
40
-    "SELECT count(*),`Column1`,`Testing`, `Testing Three` FROM `Table1`
41
-    WHERE Column1 = 'testing' AND ( (`Column2` = `Column3` OR Column4 >= NOW()) )
42
-    GROUP BY Column1 ORDER BY Column3 DESC LIMIT 5,10",
43
-
44
-    "select * from `Table`, (SELECT group_concat(column1) as col FROM Table2 GROUP BY category)
45
-    Table2, Table3 where Table2.col = (Table3.col2 - `Table`.id)",
46
-
47
-    "insert ignore into Table3 (column1, column2) VALUES ('test1','test2'), ('test3','test4');",
48
-
49
-    "UPDATE MyTable SET name='sql', category='databases' WHERE id > '65'",
50
-
51
-    "delete from MyTable WHERE name LIKE \"test%\"",
52
-
53
-    "SELECT * FROM UnmatchedParens WHERE ( A = B)) AND (((Test=1)",
54
-
55
-    "-- This is a comment
56
-    SELECT
57
-    /* This is another comment
58
-    On more than one line */
59
-    Id #This is one final comment
60
-    as temp, DateCreated as Created FROM MyTable;",
61
-);
62
-
63
-// Example statements for splitting SQL strings into individual queries
64
-$split_statements = array(
65
-    "DROP TABLE IF EXISTS MyTable;
66
-    CREATE TABLE MyTable ( id int );
67
-    INSERT INTO MyTable    (id)
68
-        VALUES
69
-        (1),(2),(3),(4);
70
-    SELECT * FROM MyTable;",
71
-
72
-    "SELECT \";\"; SELECT \";\\\"; a;\";
73
-    SELECT \";
74
-        abc\";
75
-    SELECT a,b #comment;
76
-    FROM test;",
77
-);
78
-
79
-// Example statements for removing comments
80
-$comment_statements = array(
81
-    "-- This is a comment
82
-    SELECT
83
-    /* This is another comment
84
-    On more than one line */
85
-    Id #This is one final comment
86
-    as temp, DateCreated as Created FROM MyTable;",
87
-);
88
-?>
89
-
90
-
91
-<h1>Formatting And Syntax Highlighting</h1>
92
-
93
-<div>
94
-    Usage:
95
-    <pre>
96
-    <?php highlight_string('<?php' . "\n" . '$formatted = SqlFormatter::format($sql);' . "\n" . '?>'); ?>
97
-    </pre>
98
-</div>
99
-<table>
100
-    <tr>
101
-        <th>Original</th>
102
-        <th>Formatted And Highlighted</th>
103
-    </tr>
104
-    <?php foreach ($statements as $sql) { ?>
105
-    <tr>
106
-        <td>
107
-            <pre><?php echo $sql; ?></pre>
108
-        </td>
109
-        <td><?php echo SqlFormatter::format($sql); ?></td>
110
-    </tr>
111
-    <?php }    ?>
112
-</table>
113
-
114
-
115
-<h1>Formatting Only</h1>
116
-
117
-<div>
118
-    Usage:
119
-    <pre>
120
-    <?php highlight_string('<?php' . "\n" . '$formatted = SqlFormatter::format($sql, false);' . "\n" . '?>'); ?>
121
-    </pre>
122
-</div>
123
-<table>
124
-    <tr>
125
-        <th>Original</th>
126
-        <th>Formatted</th>
127
-    </tr>
128
-    <?php foreach ($statements as $sql) { ?>
129
-    <tr>
130
-        <td>
131
-            <pre><?php echo $sql; ?></pre>
132
-        </td>
133
-        <td><pre><?php echo htmlentities(SqlFormatter::format($sql,false)); ?></pre></td>
134
-    </tr>
135
-    <?php }    ?>
136
-</table>
137
-
138
-
139
-<h1>Syntax Highlighting Only</h1>
140
-
141
-<div>
142
-    Usage:
143
-    <pre>
144
-    <?php highlight_string('<?php' . "\n" . '$highlighted = SqlFormatter::highlight($sql);' . "\n" . '?>'); ?>
145
-    </pre>
146
-</div>
147
-<table>
148
-    <tr>
149
-        <th>Original</th>
150
-        <th>Highlighted</th>
151
-    </tr>
152
-    <?php foreach ($statements as $sql) { ?>
153
-    <tr>
154
-        <td>
155
-            <pre><?php echo $sql; ?></pre>
156
-        </td>
157
-        <td><?php echo SqlFormatter::highlight($sql); ?></td>
158
-    </tr>
159
-    <?php }    ?>
160
-</table>
161
-
162
-
163
-<h1>Splitting SQL Strings Into Individual Queries</h1>
164
-
165
-<div>
166
-    Usage:
167
-    <pre>
168
-    <?php highlight_string('<?php' . "\n" . '$queries = SqlFormatter::splitQuery($sql);' . "\n" . '?>'); ?>
169
-    </pre>
170
-</div>
171
-<table>
172
-    <tr>
173
-        <th>Original</th>
174
-        <th>Split</th>
175
-    </tr>
176
-    <?php foreach ($split_statements as $sql) { ?>
177
-    <tr>
178
-        <td>
179
-            <pre><?php echo SqlFormatter::highlight($sql); ?></pre>
180
-        </td>
181
-        <td><?php
182
-            $queries = SqlFormatter::splitQuery($sql);
183
-            echo "<ol>";
184
-            foreach ($queries as $query) {
185
-                echo "<li><pre>" . SqlFormatter::highlight($query) . "</pre></li>";
186
-            }
187
-            echo "</ol>";
188
-            ?></td>
189
-    </tr>
190
-    <?php }    ?>
191
-</table>
192
-
193
-
194
-<h1>Removing Comments</h1>
195
-
196
-<div>
197
-    Usage:
198
-    <pre>
199
-    <?php highlight_string('<?php' . "\n" . '$nocomments = SqlFormatter::removeComments($sql);' . "\n" . '?>'); ?>
200
-    </pre>
201
-</div>
202
-<table>
203
-    <tr>
204
-        <th>Original</th>
205
-        <th>Comments Removed</th>
206
-    </tr>
207
-    <?php foreach ($comment_statements as $sql) { ?>
208
-    <tr>
209
-        <td>
210
-            <pre><?php echo SqlFormatter::highlight($sql); ?></pre>
211
-        </td>
212
-        <td>
213
-            <pre><?php echo SqlFormatter::highlight(SqlFormatter::removeComments($sql)) ?></pre>
214
-        </td>
215
-    </tr>
216
-    <?php }    ?>
217
-</table>
218
-
219
-</body>
220
-</html>

+ 0 - 705
vendor/jdorn/sql-formatter/lib/SqlFormatter.php View File

@@ -1,705 +0,0 @@
1
-<?php
2
-/**
3
- * SQL Formatter is a collection of utilities for debugging SQL queries.
4
- * It includes methods for formatting, syntax highlighting, removing comments, etc.
5
- *
6
- * @package    SqlFormatter
7
- * @author     Jeremy Dorn <jeremy@jeremydorn.com>
8
- * @copyright  2012 Jeremy Dorn
9
- * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
10
- * @link       http://github.com/jdorn/sql-formatter
11
- * @version    1.2.0
12
- */
13
-class SqlFormatter
14
-{
15
-    // Reserved words (for syntax highlighting)
16
-    protected static $reserved = array(
17
-        'ACCESSIBLE', 'ACTION', 'ADD', 'AFTER', 'AGAINST', 'AGGREGATE', 'ALGORITHM', 'ALL', 'ALTER', 'ANALYSE', 'ANALYZE', 'AND', 'AS', 'ASC',
18
-        'AUTOCOMMIT', 'AUTO_INCREMENT', 'AVG_ROW_LENGTH', 'BACKUP', 'BEGIN', 'BETWEEN', 'BINLOG', 'BOTH', 'BY', 'CASCADE', 'CASE', 'CHANGE', 'CHANGED',
19
-        'CHARSET', 'CHECK', 'CHECKSUM', 'COLLATE', 'COLLATION', 'COLUMN', 'COLUMNS', 'COMMENT', 'COMMIT', 'COMMITTED', 'COMPRESSED', 'CONCURRENT',
20
-        'CONSTRAINT', 'CONTAINS', 'CONVERT', 'COUNT', 'CREATE', 'CROSS', 'CURRENT_TIMESTAMP', 'DATABASE', 'DATABASES', 'DAY', 'DAY_HOUR', 'DAY_MINUTE',
21
-        'DAY_SECOND', 'DEFINER', 'DELAYED', 'DELAY_KEY_WRITE', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DIV',
22
-        'DO', 'DROP', 'DUMPFILE', 'DUPLICATE', 'DYNAMIC', 'ELSE', 'ENCLOSED', 'END', 'ENGINE', 'ENGINES', 'ESCAPE', 'ESCAPED', 'EVENTS', 'EXECUTE',
23
-        'EXISTS', 'EXPLAIN', 'EXTENDED', 'FAST', 'FIELDS', 'FILE', 'FIRST', 'FIXED', 'FLUSH', 'FOR', 'FORCE', 'FOREIGN', 'FROM', 'FULL', 'FULLTEXT',
24
-        'FUNCTION', 'GEMINI', 'GEMINI_SPIN_RETRIES', 'GLOBAL', 'GRANT', 'GRANTS', 'GROUP', 'GROUP_CONCAT', 'GROUP BY', 'HAVING', 'HEAP', 'HIGH_PRIORITY', 'HOSTS', 'HOUR', 'HOUR_MINUTE',
25
-        'HOUR_SECOND', 'IDENTIFIED', 'IF', 'IGNORE', 'IN', 'INDEX', 'INDEXES', 'INFILE', 'INNER', 'INNER JOIN', 'INSERT', 'INSERT_ID', 'INSERT_METHOD', 'INTERVAL',
26
-        'INTO', 'INVOKER', 'IS', 'ISOLATION', 'JOIN', 'KEY', 'KEYS', 'KILL', 'LAST_INSERT_ID', 'LEADING', 'LEFT', 'LEFT JOIN', 'LEVEL', 'LIKE', 'LIMIT', 'LINEAR',
27
-        'LINES', 'LOAD', 'LOCAL', 'LOCK', 'LOCKS', 'LOGS', 'LOW_PRIORITY', 'MARIA', 'MASTER', 'MASTER_CONNECT_RETRY', 'MASTER_HOST', 'MASTER_LOG_FILE',
28
-        'MASTER_LOG_POS', 'MASTER_PASSWORD', 'MASTER_PORT', 'MASTER_USER', 'MATCH', 'MAX_CONNECTIONS_PER_HOUR', 'MAX_QUERIES_PER_HOUR',
29
-        'MAX_ROWS', 'MAX_UPDATES_PER_HOUR', 'MAX_USER_CONNECTIONS', 'MEDIUM', 'MERGE', 'MINUTE', 'MINUTE_SECOND', 'MIN_ROWS', 'MODE', 'MODIFY',
30
-        'MONTH', 'MRG_MYISAM', 'MYISAM', 'NAMES', 'NATURAL', 'NOT', 'NOW', 'NULL', 'OFFSET', 'ON', 'OPEN', 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'OR',
31
-        'ORDER', 'ORDER BY', 'OUTER', 'OUTER JOIN', 'OUTFILE', 'PACK_KEYS', 'PAGE', 'PARTIAL', 'PARTITION', 'PARTITIONS', 'PASSWORD', 'PRIMARY', 'PRIVILEGES', 'PROCEDURE',
32
-        'PROCESS', 'PROCESSLIST', 'PURGE', 'QUICK', 'RAID0', 'RAID_CHUNKS', 'RAID_CHUNKSIZE', 'RAID_TYPE', 'RANGE', 'READ', 'READ_ONLY',
33
-        'READ_WRITE', 'REFERENCES', 'REGEXP', 'RELOAD', 'RENAME', 'REPAIR', 'REPEATABLE', 'REPLACE', 'REPLICATION', 'RESET', 'RESTORE', 'RESTRICT',
34
-        'RETURN', 'RETURNS', 'REVOKE', 'RIGHT', 'RIGHT JOIN', 'RLIKE', 'ROLLBACK', 'ROW', 'ROWS', 'ROW_FORMAT', 'SECOND', 'SECURITY', 'SELECT', 'SEPARATOR',
35
-        'SERIALIZABLE', 'SESSION', 'SET', 'SHARE', 'SHOW', 'SHUTDOWN', 'SLAVE', 'SONAME', 'SOUNDS', 'SQL', 'SQL_AUTO_IS_NULL', 'SQL_BIG_RESULT',
36
-        'SQL_BIG_SELECTS', 'SQL_BIG_TABLES', 'SQL_BUFFER_RESULT', 'SQL_CACHE', 'SQL_CALC_FOUND_ROWS', 'SQL_LOG_BIN', 'SQL_LOG_OFF',
37
-        'SQL_LOG_UPDATE', 'SQL_LOW_PRIORITY_UPDATES', 'SQL_MAX_JOIN_SIZE', 'SQL_NO_CACHE', 'SQL_QUOTE_SHOW_CREATE', 'SQL_SAFE_UPDATES',
38
-        'SQL_SELECT_LIMIT', 'SQL_SLAVE_SKIP_COUNTER', 'SQL_SMALL_RESULT', 'SQL_WARNINGS', 'START', 'STARTING', 'STATUS', 'STOP', 'STORAGE',
39
-        'STRAIGHT_JOIN', 'STRING', 'STRIPED', 'SUPER', 'TABLE', 'TABLES', 'TEMPORARY', 'TERMINATED', 'THEN', 'TO', 'TRAILING', 'TRANSACTIONAL',
40
-        'TRUNCATE', 'TYPE', 'TYPES', 'UNCOMMITTED', 'UNION', 'UNIQUE', 'UNLOCK', 'UPDATE', 'USAGE', 'USE', 'USING', 'VALUES', 'VARIABLES',
41
-        'VIEW', 'WHEN', 'WHERE', 'WITH', 'WORK', 'WRITE', 'XOR', 'YEAR_MONTH'
42
-    );
43
-
44
-    // For SQL formatting
45
-    // These keywords will all be on their own line
46
-    protected static $special_reserved = array(
47
-        'SELECT', 'FROM', 'WHERE', 'SET', 'ORDER BY', 'GROUP BY', 'LEFT JOIN', 'OUTER JOIN', 'INNER JOIN', 'RIGHT JOIN', 'JOIN', 'LIMIT', 'VALUES', 'UPDATE', 'HAVING'
48
-    );
49
-
50
-    // Punctuation that can be used as a boundary between other tokens
51
-    protected static $boundaries = array(',', ';', ')', '(', '.', '=', '<', '>', '+', '-', '*', '/', '!', '^', '%', '|', '&');
52
-
53
-    // White space characters.  These can also be used as a boundary between other tokens
54
-    protected static $whitespace = array(' ', "\n", "\t", "\r");
55
-
56
-    // Start of quoted strings
57
-    protected static $quotes = array('"', "'", '`');
58
-
59
-    // For syntax highlighting
60
-    // Styles applied to different token types
61
-    public static $quote_style = 'color: blue;';
62
-    public static $backtick_quote_style = 'color: purple;';
63
-    public static $reserved_style = 'color:black; font-weight:bold;';
64
-    public static $boundary_style = 'color:black;';
65
-    public static $number_style = 'color: green;';
66
-    public static $default_style = 'color: #333;';
67
-    public static $error_style = 'background-color: red; color: black;';
68
-    public static $comment_style = 'color: #aaa;';
69
-
70
-    // The tab character to use when formatting SQL
71
-    public static $tab = '  ';
72
-
73
-    // This flag tells us if SqlFormatted has been initialized
74
-    protected static $init;
75
-
76
-    // This is a combination of all the boundary characters and all the whitespace characters
77
-    protected static $all_boundaries;
78
-
79
-    //cache variables
80
-    //Only tokens shorter than this size will be cached.  Somewhere between 10 and 20 seems to work well for most cases.
81
-    public static $max_cachekey_size = 15;
82
-    protected static $token_cache = array();
83
-    protected static $cache_hits = 0;
84
-    protected static $cache_misses = 0;
85
-    
86
-    /**
87
-     * Get stats about the token cache
88
-     * @return Array An array containing the keys 'hits', 'misses', 'entries', and 'size' in bytes
89
-     */
90
-    public static function getCacheStats() {
91
-        return array(
92
-            'hits'=>self::$cache_hits,
93
-            'misses'=>self::$cache_misses,
94
-            'entries'=>count(self::$token_cache),
95
-            'size'=>strlen(serialize(self::$token_cache))
96
-        );
97
-    }
98
-    
99
-    /**
100
-     * Return the next token and token type in a SQL string.
101
-     * Quoted strings, comments, reserved words, whitespace, and punctuation are all their own tokens.
102
-     *
103
-     * @param String $string The SQL string
104
-     * @param array $previous The result of the previous getNextToken() call
105
-     *
106
-     * @return Array An associative array containing a 'token' and 'type' key.
107
-     */
108
-    protected static function getNextToken($string, $previous = null)
109
-    {
110
-        // If the next token is a comment
111
-        if ($string[0] === '#' || substr($string, 0, 2) === '--' || substr($string, 0, 2) === '/*') {
112
-            // Comment until end of line
113
-            if ($string[0] === '-' || $string[0] === '#') {
114
-                $last = strpos($string, "\n");
115
-                $type = 'comment';
116
-            } else { // Comment until closing comment tag
117
-                $last = strpos($string, "*/", 2) + 2;
118
-                $type = 'block comment';
119
-            }
120
-
121
-            if ($last === false) {
122
-                $last = strlen($string);
123
-            }
124
-
125
-            return array(
126
-                'token' => substr($string, 0, $last),
127
-                'type'  => $type
128
-            );
129
-        }
130
-
131
-        // If the next item is a string
132
-        if (in_array($string[0], self::$quotes)) {
133
-            $quote = $string[0];
134
-            for ($i = 1, $length = strlen($string); $i < $length; $i++) {
135
-                $next_char = null;
136
-                if (isset($string[$i + 1])) {
137
-                    $next_char = $string[$i + 1];
138
-                }
139
-
140
-                // Escaped (either backslash or backtick escaped)
141
-                if (($quote !== '`' && $string[$i] === '\\') || ($quote === '`' && $string[$i] === '`' && $next_char === '`')) {
142
-                    $i++;
143
-                } elseif ($string[$i] === $quote) {
144
-                    break;
145
-                }
146
-            }
147
-            if ($quote === '`') {
148
-                $type = 'backtick quote';
149
-            } else {
150
-                $type = 'quote';
151
-            }
152
-
153
-            return array(
154
-                'token' => substr($string, 0, $i + 1),
155
-                'type'  => $type
156
-            );
157
-        }
158
-
159
-        // Separators
160
-        if (in_array($string[0], self::$boundaries)) {
161
-            // If it is a simple string or empty between the parentheses, just count as a word
162
-            // this makes it so we don't split things like NOW() or COUNT(*) into separate lines
163
-            if ($string[0] === '(') {
164
-                // "()"
165
-                if (isset($string[1]) && $string[1] === ')') {
166
-                    return array(
167
-                        'token' => '()',
168
-                        'type'  => 'word'
169
-                    );
170
-                }
171
-
172
-                // "(word/whitespace/boundary)"
173
-                $next_token = self::getNextToken(substr($string, 1));
174
-                $length = strlen($next_token['token']);
175
-                if (isset($string[$length + 1]) && $string[$length + 1] === ')') {
176
-                    if ($next_token['type'] === 'word' || $next_token['type'] === 'whitespace' || $next_token['type'] === 'boundary') {
177
-                        return array(
178
-                            'token' => '(' . $next_token['token'] . ')',
179
-                            'type'  => 'word'
180
-                        );
181
-                    }
182
-                }
183
-            }
184
-
185
-            //return single parentheses as their own token
186
-            if ($string[0] === '(' || $string[0] === ')') {
187
-                return array(
188
-                    'token' => $string[0],
189
-                    'type'  => $string[0]
190
-                );
191
-            }
192
-
193
-
194
-            // If there are 1 or more boundary characters together, return as a single word
195
-            $next_token = self::getNextToken(substr($string, 1));
196
-            if ($next_token['type'] === 'boundary') {
197
-                return array(
198
-                    'token' => $string[0].$next_token['token'],
199
-                    'type'  => 'boundary'
200
-                );
201
-            }
202
-
203
-            // Otherwise, just return the single boundary character
204
-            if ($string[0] === '.' || $string[0] === ',') {
205
-                $type = $string[0];
206
-            } else {
207
-                $type = 'boundary';
208
-            }
209
-
210
-            return array(
211
-                'token' => $string[0],
212
-                'type'  => $type
213
-            );
214
-        }
215
-
216
-        // Whitespace
217
-        if (in_array($string[0], self::$whitespace)) {
218
-            for ($i = 1, $length = strlen($string); $i < $length; $i++) {
219
-                if (!in_array($string[$i], self::$whitespace)) {
220
-                    break;
221
-                }
222
-            }
223
-
224
-            return array(
225
-                'token' => substr($string, 0, $i),
226
-                'type'  => 'whitespace'
227
-            );
228
-        }
229
-
230
-        if (!self::$init) {
231
-            //Sort reserved word list from longest word to shortest
232
-            usort(self::$reserved, array('SqlFormatter', 'sortLength'));
233
-
234
-            //Combine boundary characters and whitespace
235
-            self::$all_boundaries = array_merge(self::$boundaries, self::$whitespace);
236
-
237
-            self::$init = true;
238
-        }
239
-
240
-        //a reserved word cannot be preceded by a '.'
241
-        //this makes it so in "mytable.from", "from" is not considered a reserved word
242
-        if (!$previous || !isset($previous['token']) || $previous['token'] !== '.') {
243
-            // Reserved word
244
-            $test = strtoupper($string);
245
-            foreach (self::$reserved as $word) {
246
-                $length = strlen($word);
247
-                if (substr($test, 0, $length) === $word) {
248
-                    if (isset($string[$length]) && !in_array($string[$length], self::$all_boundaries)) {
249
-                        continue;
250
-                    }
251
-
252
-                    if (in_array($word, self::$special_reserved)) {
253
-                        $type = 'special reserved';
254
-                    } else {
255
-                        $type = 'reserved';
256
-                    }
257
-
258
-                    return array(
259
-                        'token' => substr($string, 0, $length),
260
-                        'type'  => $type
261
-                    );
262
-                }
263
-            }
264
-        }
265
-
266
-        // Look for first word separator
267
-        for ($i = 1, $length = strlen($string); $i < $length; $i++) {
268
-            if (in_array($string[$i], self::$all_boundaries)) {
269
-                break;
270
-            }
271
-        }
272
-
273
-        $ret = substr($string, 0, $i);
274
-        if (is_numeric($ret)) {
275
-            $type = 'number';
276
-        } else {
277
-            $type = 'word';
278
-        }
279
-
280
-        return array(
281
-            'token' => $ret,
282
-            'type'  => $type
283
-        );
284
-    }
285
-
286
-    /**
287
-     * Takes a SQL string and breaks it into tokens.
288
-     * Each token is an associative array with a 'token' and 'type' key.
289
-     *
290
-     * @param String $string The SQL string
291
-     *
292
-     * @throws Exception when there is a problem tokenizing the input string
293
-     *
294
-     * @return Array An array of tokens.
295
-     */
296
-    protected static function tokenize($string)
297
-    {
298
-        $tokens = array();
299
-
300
-        //used for debugging if there is an error while tokenizing the string
301
-        $original_length = strlen($string);
302
-
303
-        //used to make sure the string keeps shrinking on each iteration
304
-        $old_string_len = strlen($string) + 1;
305
-
306
-        $token = null;
307
-        
308
-        $current_length = strlen($string);
309
-
310
-        // Keep processing the string until it is empty
311
-        while ($current_length) {
312
-            // If the string stopped shrinking, there was a problem
313
-            if ($old_string_len <= $current_length) {
314
-                throw new Exception("SQL Parse Error - Unable to tokenize string at character ".($original_length - $old_string_len));
315
-            }
316
-            $old_string_len =  $current_length;
317
-
318
-            // Determine if we can use caching
319
-            if($current_length >= self::$max_cachekey_size) {
320
-                $cacheKey = substr($string,0,self::$max_cachekey_size);
321
-            }
322
-            else {
323
-                $cacheKey = false;
324
-            }
325
-
326
-            // See if the token is already cached
327
-            if($cacheKey && isset(self::$token_cache[$cacheKey])) {
328
-                //retrieve from cache
329
-                $token = self::$token_cache[$cacheKey];
330
-                $token_length = strlen($token['token']);
331
-                self::$cache_hits++;
332
-            }
333
-            else {
334
-                // Get the next token and the token type
335
-                $token = self::getNextToken($string, $token);
336
-                $token_length = strlen($token['token']);
337
-                self::$cache_misses++;
338
-                
339
-                // If the token is shorter than the max length, store it in cache
340
-                if($cacheKey && $token_length < self::$max_cachekey_size) {
341
-                    self::$token_cache[$cacheKey] = $token;
342
-                }
343
-            }
344
-            
345
-            $tokens[] = $token;
346
-
347
-            //advance the string
348
-            $string = substr($string, $token_length);
349
-            
350
-            $current_length -= $token_length;
351
-        }
352
-
353
-        return $tokens;
354
-    }
355
-
356
-    /**
357
-     * Format the whitespace in a SQL string to make it easier to read.
358
-     *
359
-     * @param String  $string    The SQL string
360
-     * @param boolean $highlight If true, syntax highlighting will also be performed
361
-     *
362
-     * @throws Exception when there is a problem tokenizing the input string
363
-     *
364
-     * @return String The SQL string with HTML styles and formatting wrapped in a <pre> tag
365
-     */
366
-    public static function format($string, $highlight=true)
367
-    {
368
-        // This variable will be populated with formatted html
369
-        $return = '';
370
-
371
-        // Configuration values
372
-        $tab = self::$tab;
373
-
374
-        // Starting values
375
-        $indent = 1;
376
-        $newline = false;
377
-        $indented = false;
378
-        $extra_indent = 0;
379
-
380
-        // Tokenize String
381
-        $tokens = self::tokenize($string);
382
-
383
-        foreach ($tokens as $i=>$token) {
384
-            // Get highlighted token if doing syntax highlighting
385
-            if ($highlight) {
386
-                $highlighted = self::highlightToken($token);
387
-            } else { // If returning raw text
388
-                $highlighted = $token['token'];
389
-            }
390
-
391
-            // Don't process whitespace
392
-            if ($token['type'] === 'whitespace') {
393
-                continue;
394
-            }
395
-
396
-            // Display comments directly where they appear in the source
397
-            if ($token['type'] === 'comment' || $token['type'] === 'block comment') {
398
-                if ($token['type'] === 'block comment') {
399
-                    $return .= "\n" . str_repeat($tab, $indent);
400
-                }
401
-
402
-                $return .= $highlighted;
403
-                $newline = true;
404
-                continue;
405
-            }
406
-
407
-            // If this token decreases the indent level
408
-            if ($token['type'] === 'special reserved' || $token['type'] === ')') {
409
-                if ($indented) {
410
-                    ++$extra_indent;
411
-                } elseif ($indent && ($token['type'] === 'special reserved' || $indent > 1)) {
412
-                    --$indent;
413
-
414
-                    if ($token['type'] === ')' && $extra_indent) {
415
-                        $indent -= $extra_indent;
416
-                        $extra_indent = 0;
417
-                    }
418
-                } else { // If there are mismatched parentheses
419
-                    if ($highlight) {
420
-                        $return .= self::highlightError(htmlentities($token['token'])).' ';
421
-                    } else {
422
-                        $return .= $highlighted;
423
-                    }
424
-
425
-                    continue;
426
-                }
427
-            }
428
-
429
-            // If we need a new line before the token
430
-            if ($newline || ($token['type'] === ')' || $token['type'] === 'special reserved')) {
431
-                $newline = false;
432
-                $return .= "\n" . str_repeat($tab, $indent);
433
-            }
434
-
435
-            // If we need a new line after the token
436
-            if ($token['type'] === ',' || $token['type'] === '(' || $token['type'] === 'special reserved') {
437
-                $newline = true;
438
-            }
439
-
440
-            // If this token increases the indent level
441
-            if ($token['type'] === 'special reserved' || $token['type'] === '(') {
442
-                ++$indent;
443
-                $indented = true;
444
-            } else {
445
-                $indented = false;
446
-            }
447
-
448
-            // If the token shouldn't have a space before it
449
-            if ($token['token'] === '.' || $token['token'] === ',' || $token['token'] === ';') {
450
-                $return = rtrim($return, ' ');
451
-            }
452
-
453
-            //if this is an opening parentheses, take out the preceding space unless there was whitespace there in the
454
-            //original query
455
-            if ($token['token'][0] === '(' && isset($tokens[$i-1]) && $tokens[$i-1]['type'] !== 'whitespace') {
456
-                $return = rtrim($return,' ');
457
-            }
458
-
459
-            $return .= $highlighted.' ';
460
-
461
-            // If the token shouldn't have a space after it
462
-            if ($token['token'] === '(' || $token['token'] === '.') {
463
-                $return = rtrim($return,' ');
464
-            }
465
-        }
466
-
467
-        // If there are unmatched parentheses
468
-        if ($highlight && $indent !== 1) {
469
-            $return .= "\n".self::highlightError("WARNING: unclosed parentheses or section");
470
-        }
471
-
472
-        if ($highlight) {
473
-            return "<pre style='background:white;'>" . trim($return) . "</pre>";
474
-        }
475
-
476
-        return trim($return);
477
-    }
478
-
479
-    /**
480
-     * Add syntax highlighting to a SQL string
481
-     *
482
-     * @param String $string The SQL string
483
-     *
484
-     * @throws Exception when there is a problem tokenizing the input string
485
-     *
486
-     * @return String The SQL string with HTML styles applied
487
-     */
488
-    public static function highlight($string)
489
-    {
490
-        $tokens = self::tokenize($string);
491
-
492
-        $return = '';
493
-
494
-        foreach ($tokens as $token) {
495
-            $return .= self::highlightToken($token);
496
-        }
497
-
498
-        return "<pre style='background:white;'>" . trim($return) . "</pre>";
499
-    }
500
-
501
-    /**
502
-     * Split a SQL string into multiple queries.
503
-     * Uses ";" as a query delimiter.
504
-     *
505
-     * @param String $string The SQL string
506
-     *
507
-     * @throws Exception when there is a problem tokenizing the input string
508
-     *
509
-     * @return Array An array of individual query strings without trailing semicolons
510
-     */
511
-    public static function splitQuery($string)
512
-    {
513
-        // Comments between queries cause problems, so remove them first
514
-        $string = self::removeComments($string);
515
-
516
-        $queries = array();
517
-        $current_query = '';
518
-
519
-        $tokens = self::tokenize($string);
520
-
521
-        foreach ($tokens as $token) {
522
-            // If this is a query separator
523
-            if ($token['token'] === ';') {
524
-                if (trim($current_query)) {
525
-                    $queries[] = trim($current_query);
526
-                }
527
-                $current_query = '';
528
-                continue;
529
-            }
530
-
531
-            $current_query .= $token['token'];
532
-        }
533
-
534
-        if (trim($current_query)) {
535
-            $queries[] = trim($current_query);
536
-        }
537
-
538
-        return $queries;
539
-    }
540
-
541
-    /**
542
-     * Remove all comments from a SQL string
543
-     *
544
-     * @param String $string The SQL string
545
-     *
546
-     * @throws Exception when there is a problem tokenizing the input string
547
-     *
548
-     * @return String The SQL string without comments
549
-     */
550
-    public static function removeComments($string)
551
-    {
552
-        $result = '';
553
-
554
-        $tokens = self::tokenize($string);
555
-
556
-        foreach ($tokens as $token) {
557
-            // Skip comment tokens
558
-            if ($token['type'] === 'comment' || $token['type'] === 'block comment') {
559
-                continue;
560
-            }
561
-
562
-            $result .= $token['token'];
563
-        }
564
-
565
-        return $result;
566
-    }
567
-
568
-    /**
569
-     * Highlights a token depending on its type.
570
-     *
571
-     * @param Array $token An associative array containing 'token' and 'type' keys.
572
-     *
573
-     * @return String HTML code of the highlighted token.
574
-     */
575
-    protected static function highlightToken($token)
576
-    {
577
-        $type = $token['type'];
578
-        $token = htmlentities($token['token']);
579
-
580
-        switch ($type) {
581
-                case 'backtick quote':
582
-                case 'quote':
583
-                    return self::highlightQuote($token, $type);
584
-                case 'reserved':
585
-                case 'special reserved':
586
-                    return self::highlightReservedWord($token);
587
-                case '(':
588
-                case ')':
589
-                    return $token;
590
-                case 'number':
591
-                    return self::highlightNumber($token);
592
-                case 'boundary':
593
-                case '.':
594
-                case ',':
595
-                    return self::highlightBoundary($token);
596
-                case 'comment':
597
-                case 'block comment':
598
-                    return self::highlightComment($token);
599
-                default:
600
-                    return self::highlightDefault($token);
601
-            }
602
-    }
603
-
604
-    /**
605
-     * Highlights a quoted string
606
-     *
607
-     * @param String $value The token's value
608
-     * @param String $type  The token's type
609
-     *
610
-     * @return String HTML code of the highlighted token.
611
-     */
612
-    protected static function highlightQuote($value, $type)
613
-    {
614
-        if ($type === 'backtick quote') {
615
-            return "<span style='" . self::$backtick_quote_style . "'>" . $value . "</span>";
616
-        }
617
-
618
-        return "<span style='" . self::$quote_style . "'>" . $value . "</span>";
619
-    }
620
-
621
-    /**
622
-     * Highlights a reserved word
623
-     *
624
-     * @param String $value The token's value
625
-     *
626
-     * @return String HTML code of the highlighted token.
627
-     */
628
-    protected static function highlightReservedWord($value)
629
-    {
630
-        return "<span style='" . self::$reserved_style . "'>" . $value . "</span>";
631
-    }
632
-
633
-    /**
634
-     * Highlights a boundary token
635
-     *
636
-     * @param String $value The token's value
637
-     *
638
-     * @return String HTML code of the highlighted token.
639
-     */
640
-    protected static function highlightBoundary($value)
641
-    {
642
-        return "<span style='" . self::$boundary_style . "'>" . $value . "</span>";
643
-    }
644
-
645
-    /**
646
-     * Highlights a number
647
-     *
648
-     * @param String $value The token's value
649
-     *
650
-     * @return String HTML code of the highlighted token.
651
-     */
652
-    protected static function highlightNumber($value)
653
-    {
654
-        return "<span style='" . self::$number_style . "'>" . $value . "</span>";
655
-    }
656
-
657
-    /**
658
-     * Highlights an error
659
-     *
660
-     * @param String $value The token's value
661
-     *
662
-     * @return String HTML code of the highlighted token.
663
-     */
664
-    protected static function highlightError($value)
665
-    {
666
-        return "<span style='" . self::$error_style . "'>" . $value . "</span>";
667
-    }
668
-
669
-    /**
670
-     * Highlights a comment
671
-     *
672
-     * @param String $value The token's value
673
-     *
674
-     * @return String HTML code of the highlighted token.
675
-     */
676
-    protected static function highlightComment($value)
677
-    {
678
-        return "<span style='" . self::$comment_style . "'>" . $value . "</span>";
679
-    }
680
-
681
-    /**
682
-     * Highlights a generic token
683
-     *
684
-     * @param String $value The token's value
685
-     *
686
-     * @return String HTML code of the highlighted token.
687
-     */
688
-    protected static function highlightDefault($value)
689
-    {
690
-        return "<span style='" . self::$default_style . "'>" . $value . "</span>";
691
-    }
692
-
693
-    /**
694
-     * Helper function for sorting the list of reserved words by length
695
-     *
696
-     * @param String $a The first string
697
-     * @param String $b The second string
698
-     *
699
-     * @return int The comparison of the string lengths
700
-     */
701
-    private static function sortLength($a, $b)
702
-    {
703
-        return strlen($b) - strlen($a);
704
-    }
705
-}

+ 0 - 44
vendor/jdorn/sql-formatter/tests/performance.php View File

@@ -1,44 +0,0 @@
1
-<?php
2
-require '../lib/SqlFormatter.php';
3
-//this is the default value
4
-//set to '0' to disable caching
5
-//a value between 10 and 20 seems to give the best result
6
-SqlFormatter::$max_cachekey_size = 15;
7
-
8
-$contents = file('sql.sql');
9
-
10
-//track time and memory usage
11
-$start = microtime(true);
12
-$ustart = memory_get_usage(true);
13
-
14
-//track number of queries and size of queries
15
-$queries = 0;
16
-$bytes = 0;
17
-
18
-//format each query 3 times
19
-for ($i =0; $i<3; $i++) {
20
-    foreach ($contents as $query) {
21
-		//this tries to mix up the queries so we aren't just running the same thing a bunch of times
22
-        $query = str_replace('tablename', rand(1, 10000), $query);
23
-
24
-		//do formatting and highlighting
25
-        SqlFormatter::format($query);
26
-        
27
-        $queries++;
28
-        $bytes += strlen($query);
29
-    }
30
-}
31
-
32
-$uend = memory_get_usage(true);
33
-$end = microtime(true);
34
-
35
-echo "<p>Formatted $queries queries.</p>";
36
-
37
-echo "<p>Average query length of ".number_format($bytes/$queries,5)." characters</p>";
38
-
39
-echo "<p>Took ".number_format($end-$start,5)." seconds total, ".number_format(($end-$start)/$queries,5)." seconds per query, ".number_format(1000*($end-$start)/$bytes,5)." seconds per 1000 characters</p>";
40
-
41
-echo "<p>Used ".number_format($uend-$ustart)." bytes of memory</p>";
42
-
43
-echo "<h3>Cache Stats</h3><pre>".print_r(SqlFormatter::getCacheStats(),true)."</pre>";
44
-

+ 0 - 61
vendor/jdorn/sql-formatter/tests/sql.sql View File

@@ -1,61 +0,0 @@
1
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
2
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
3
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
4
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
5
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
6
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
7
-CREATE DATABASE myNewDatabase
8
-DROP DATABASE database_name , database_name
9
-USE master
10
-EXEC sp_dboption myOldData, 'Single User', TRUE
11
-EXEC sp_renamedb 'myOldData', 'myNewData'
12
-EXEC sp_dboption myNewData, 'Single User', FALSE
13
-CREATE TABLE tablename (COLUMN_NAME column_type [(column_width[,column_precision])] .
14
-CREATE TABLE tablename (fname     VARCHAR(20)   NOT NULL,lname     VARCHAR(30)   NOT NULL,hire_date SMALLDATETIME NULL,ssn       CHAR(11)      NOT NULL)
15
-EXECUTE sp_help practice -- shows structure of table
16
-ALTER TABLE XYZ ADD mi CHAR(1) NULL
17
-SELECT * INTO tablename FROM tablename
18
-SELECT * FROM tablename
19
-IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MyTableName' AND COLUMN_NAME = 'newcolumn') BEGIN ALTER TABLE MyTableName ADD newcolumn VARCHAR(32) NOT NULL DEFAULT '' END
20
-IF EXISTS (SELECT * FROM dbo.syscolumns WHERE id = object_id(N'[dbo].[Projects]') AND NAME = 'ProjectManager') ALTER TABLE Projects DROP COLUMN [ProjectManager]
21
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
22
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
23
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
24
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
25
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
26
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
27
-INSERT INTO tablename (1996,'ford') -- INTO is an optional keyword in SQLServer
28
-INSERT tablename VALUES ('a','b',DEFAULT,i) -- DEFAULT is a key word
29
-INSERT INTO tablename VALUES(1001,'The Odyssey','Homer',NULL)
30
-INSERT INTO TABLE (c17,c4,c8,c3)
31
-EXECUTE sp_mystored_procedure1
32
-INSERT INTO OtherDatabaseName.tablename
33
-SELECT * FROM tablename WHERE loginid ='mfincher'
34
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
35
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
36
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
37
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
38
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
39
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
40
-UPDATE tablename SET col = VALUE|col|expr
41
-UPDATE TABLE_NAME SET column_id = expr  WHERE condition
42
-UPDATE tablename SET password = 'newpass' WHERE USER = 'quest'
43
-UPDATE tablename SET password = 'newpass' WHERE (UserID > 1) AND (UserID < 113)
44
-UPDATE tablename SET password = 'newpass', change='Y' WHERE USER = 'quest'
45
-UPDATE tablename SET discount = discount + .1 WHERE lowqty >= 100
46
-UPDATE tablename SET LNAME = UPPER(LNAME)
47
-UPDATE tablename SET ytd_sales = (SELECT SUM(qty) FROM sales WHERE sales.title_id = titles.title_id AND ord_date BETWEEN '01/01/94' AND '12/31/94')
48
-INSERT adult SELECT ju.member_no,  ad.street,  ad.city,  ad.state,  ad.zip, ad.phone_no, DATEADD(YY, 1, GETDATE()) FROM tablename ju JOIN tablename ad ON ju.adult_member_no = ad.member_no WHERE (DATEADD(YY, 18, ju.birth_date) < GETDATE())
49
-DELETE FROM tablename WHERE userid < 50
50
-DELETE tablename -- deletes all rows in a table (see "DROP TABLE" to delete a table)
51
-TRUNCATE TABLE tablename -- deletes all rows, but doesn't log transaction
52
-DELETE tablename WHERE title_id IN (SELECT title_id FROM ...)
53
-SELECT str(myField, 12, 2) FROM tablename
54
-SELECT CAST(datepart(yy,dtime) AS VARCHAR(4)) + ' ' + str(datepart(dy,dtime),3)  AS 'Year  Day', COUNT(TIME) AS 'Key Question Pages', AVG(TIME) AS 'avg time (msec)' FROM tablename WHERE NAME='Key' GROUP BY CAST(datepart(yy,dtime) AS VARCHAR(4)) + ' ' + str(datepart(dy,dtime),3) ORDER BY CAST(datepart(yy,dtime) AS VARCHAR(4)) + ' ' + str(datepart(dy,dtime),3) ASC
55
-SELECT DISTINCT NAME FROM SYSDATABASES
56
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
57
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
58
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
59
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
60
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id
61
-SELECT tablename.match_id AS match_id0, tablename.match_date AS match_date1, tablename.hometeam_goals AS hometeam_goals2, tablename.awayteam_goals AS awayteam_goals3, t1_.team_id AS team_id4, t1_.name AS name5, t1_.goals_given AS goals_given6, t1_.goals_taken AS goals_taken7, t1_.wins AS wins8, t1_.draws AS draws9, t1_.losses AS losses10, t2_.team_id AS team_id11, t2_.name AS name12, t2_.goals_given AS goals_given13, t2_.goals_taken AS goals_taken14, t2_.wins AS wins15, t2_.draws AS draws16, t2_.losses AS losses17, tablename.awayteam_id AS awayteam_id18, tablename.hometeam_id AS hometeam_id19  FROM `match` tablename INNER JOIN team t1_ ON tablename.hometeam_id = t1_.team_id INNER JOIN team t2_ ON tablename.awayteam_id = t2_.team_id

+ 0 - 59
vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/JMSSecurityExtraBundle.php View File

@@ -1,59 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
-namespace JMS\SecurityExtraBundle;
20
-
21
-use JMS\SecurityExtraBundle\DependencyInjection\SecurityExtension;
22
-use JMS\SecurityExtraBundle\DependencyInjection\Compiler\IntegrationPass;
23
-use JMS\SecurityExtraBundle\DependencyInjection\Compiler\DisableVotersPass;
24
-use JMS\SecurityExtraBundle\DependencyInjection\Compiler\AddExpressionCompilersPass;
25
-use Symfony\Component\DependencyInjection\Compiler\PassConfig;
26
-use JMS\SecurityExtraBundle\DependencyInjection\Compiler\AddAfterInvocationProvidersPass;
27
-use JMS\SecurityExtraBundle\DependencyInjection\Compiler\CollectSecuredServicesPass;
28
-use Symfony\Component\DependencyInjection\ContainerBuilder;
29
-use Symfony\Component\HttpKernel\Bundle\Bundle;
30
-
31
-/**
32
- * Registers our custom compiler pass.
33
- *
34
- * @author Johannes M. Schmitt <schmittjoh@gmail.com>
35
- */
36
-class JMSSecurityExtraBundle extends Bundle
37
-{
38
-    const VERSION = '1.2.0';
39
-
40
-    public function build(ContainerBuilder $container)
41
-    {
42
-        if (!$container->hasExtension('security')) {
43
-            throw new \LogicException('The JMSSecurityExtraBundle must be registered after the SecurityBundle in your AppKernel.php.');
44
-        }
45
-        $container->registerExtension(new SecurityExtension($container->getExtension('security')));
46
-
47
-        $passConfig = $container->getCompilerPassConfig();
48
-
49
-        // needs to run before voter collection
50
-        $passes = $passConfig->getBeforeOptimizationPasses();
51
-        array_unshift($passes, new DisableVotersPass());
52
-        $passConfig->setBeforeOptimizationPasses($passes);
53
-
54
-        $passConfig->addPass(new AddAfterInvocationProvidersPass());
55
-        $passConfig->addPass(new CollectSecuredServicesPass());
56
-        $passConfig->addPass(new AddExpressionCompilersPass());
57
-        $passConfig->addPass(new IntegrationPass());
58
-    }
59
-}

+ 0 - 174
vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/DoctrineParamConverter.php View File

@@ -1,174 +0,0 @@
1
-<?php
2
-
3
-namespace Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
4
-
5
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
6
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7
-use Symfony\Component\HttpFoundation\Request;
8
-use Doctrine\Common\Persistence\ManagerRegistry;
9
-
10
-/*
11
- * This file is part of the Symfony framework.
12
- *
13
- * (c) Fabien Potencier <fabien@symfony.com>
14
- *
15
- * This source file is subject to the MIT license that is bundled
16
- * with this source code in the file LICENSE.
17
- */
18
-
19
-/**
20
- * DoctrineParamConverter.
21
- *
22
- * @author     Fabien Potencier <fabien@symfony.com>
23
- */
24
-class DoctrineParamConverter implements ParamConverterInterface
25
-{
26
-    /**
27
-     * @var ManagerRegistry
28
-     */
29
-    protected $registry;
30
-
31
-    public function __construct(ManagerRegistry $registry = null)
32
-    {
33
-        $this->registry = $registry;
34
-    }
35
-
36
-    public function apply(Request $request, ConfigurationInterface $configuration)
37
-    {
38
-        $name    = $configuration->getName();
39
-        $class   = $configuration->getClass();
40
-        $options = $this->getOptions($configuration);
41
-
42
-        // find by identifier?
43
-        if (false === $object = $this->find($class, $request, $options, $name)) {
44
-            // find by criteria
45
-            if (false === $object = $this->findOneBy($class, $request, $options)) {
46
-                if ($configuration->isOptional()) {
47
-                    $object = null;
48
-                } else {
49
-                    throw new \LogicException('Unable to guess how to get a Doctrine instance from the request information.');
50
-                }
51
-            }
52
-        }
53
-
54
-        if (null === $object && false === $configuration->isOptional()) {
55
-            throw new NotFoundHttpException(sprintf('%s object not found.', $class));
56
-        }
57
-
58
-        $request->attributes->set($name, $object);
59
-
60
-        return true;
61
-    }
62
-
63
-    protected function find($class, Request $request, $options, $name)
64
-    {
65
-        if ($options['mapping'] || $options['exclude']) {
66
-            return false;
67
-        }
68
-
69
-        $id = $this->getIdentifier($request, $options, $name);
70
-
71
-        if (false === $id) {
72
-            return false;
73
-        }
74
-
75
-        return $this->getManager($options['entity_manager'], $class)->getRepository($class)->find($id);
76
-    }
77
-
78
-    protected function getIdentifier(Request $request, $options, $name)
79
-    {
80
-        if (isset($options['id'])) {
81
-            if (!is_array($options['id'])) {
82
-                $name = $options['id'];
83
-            } elseif (is_array($options['id'])) {
84
-                $id = array();
85
-                foreach ($options['id'] as $field) {
86
-                    $id[$field] = $request->attributes->get($field);
87
-                }
88
-                return $id;
89
-            }
90
-        }
91
-
92
-        if ($request->attributes->has($name)) {
93
-            return $request->attributes->get($name);
94
-        }
95
-
96
-        if ($request->attributes->has('id')) {
97
-            return $request->attributes->get('id');
98
-        }
99
-
100
-        return false;
101
-    }
102
-
103
-    protected function findOneBy($class, Request $request, $options)
104
-    {
105
-        if (!$options['mapping']) {
106
-            $keys               = $request->attributes->keys();
107
-            $options['mapping'] = $keys ? array_combine($keys, $keys) : array();
108
-        }
109
-
110
-        foreach ($options['exclude'] as $exclude) {
111
-            unset($options['mapping'][$exclude]);
112
-        }
113
-
114
-        if (!$options['mapping']) {
115
-            return false;
116
-        }
117
-
118
-        $criteria = array();
119
-        $em = $this->getManager($options['entity_manager'], $class);
120
-        $metadata = $em->getClassMetadata($class);
121
-
122
-        foreach ($options['mapping'] as $attribute => $field) {
123
-            if ($metadata->hasField($field) || ($metadata->hasAssociation($field) && $metadata->isSingleValuedAssociation($field))) {
124
-                $criteria[$field] = $request->attributes->get($attribute);
125
-            }
126
-        }
127
-
128
-        if (!$criteria) {
129
-            return false;
130
-        }
131
-
132
-        return $em->getRepository($class)->findOneBy($criteria);
133
-    }
134
-
135
-    public function supports(ConfigurationInterface $configuration)
136
-    {
137
-        // if there is no manager, this means that only Doctrine DBAL is configured
138
-        if (null === $this->registry || !count($this->registry->getManagers())) {
139
-            return false;
140
-        }
141
-
142
-        if (null === $configuration->getClass()) {
143
-            return false;
144
-        }
145
-
146
-        $options = $this->getOptions($configuration);
147
-
148
-        // Doctrine Entity?
149
-        $em = $this->getManager($options['entity_manager'], $configuration->getClass());
150
-        if (null === $em) {
151
-            return false;
152
-        }
153
-        
154
-        return ! $em->getMetadataFactory()->isTransient($configuration->getClass());
155
-    }
156
-
157
-    protected function getOptions(ConfigurationInterface $configuration)
158
-    {
159
-        return array_replace(array(
160
-            'entity_manager' => null,
161
-            'exclude'        => array(),
162
-            'mapping'        => array(),
163
-        ), $configuration->getOptions());
164
-    }
165
-
166
-    private function getManager($name, $class)
167
-    {
168
-        if (null === $name) {
169
-            return $this->registry->getManagerForClass($class);
170
-        }
171
-
172
-        return $this->registry->getManager($name);
173
-    }
174
-}

+ 0 - 221
vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Tests/Request/ParamConverter/DoctrineParamConverterTest.php View File

@@ -1,221 +0,0 @@
1
-<?php
2
-
3
-namespace Sensio\Bundle\FrameworkExtraBundle\Tests\Request\ParamConverter;
4
-
5
-use Symfony\Component\HttpFoundation\Request;
6
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter;
7
-
8
-class DoctrineParamConverterTest extends \PHPUnit_Framework_TestCase
9
-{
10
-    /**
11
-     * @var Doctrine\Common\Persistence\ManagerRegistry
12
-     */
13
-    private $registry;
14
-
15
-    /**
16
-     * @var DoctrineParamConverter
17
-     */
18
-    private $converter;
19
-
20
-    public function setUp()
21
-    {
22
-        if (!interface_exists('Doctrine\Common\Persistence\ManagerRegistry')) {
23
-            $this->markTestSkipped();
24
-        }
25
-
26
-        $this->registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
27
-        $this->converter = new DoctrineParamConverter($this->registry);
28
-    }
29
-
30
-    public function createConfiguration($class = null, array $options = null, $name = 'arg', $isOptional = false)
31
-    {
32
-        $config = $this->getMock(
33
-            'Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface', array(
34
-            'getClass', 'getAliasName', 'getOptions', 'isOptional', 'getName',
35
-        ));
36
-        if ($options !== null) {
37
-            $config->expects($this->once())
38
-                   ->method('getOptions')
39
-                   ->will($this->returnValue($options));
40
-        }
41
-        if ($class !== null) {
42
-            $config->expects($this->any())
43
-                   ->method('getClass')
44
-                   ->will($this->returnValue($class));
45
-        }
46
-        $config->expects($this->any())
47
-               ->method('getName')
48
-               ->will($this->returnValue($name));
49
-        $config->expects($this->any())
50
-               ->method('isOptional')
51
-               ->will($this->returnValue($isOptional));
52
-
53
-        return $config;
54
-    }
55
-
56
-    public function testApplyWithNoIdAndData()
57
-    {
58
-        $request = new Request();
59
-        $config = $this->createConfiguration(null, array());
60
-        $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
61
-
62
-        $this->setExpectedException('LogicException');
63
-        $this->converter->apply($request, $config);
64
-    }
65
-
66
-    public function testApplyWithNoIdAndDataOptional()
67
-    {
68
-        $request = new Request();
69
-        $config = $this->createConfiguration(null, array(), 'arg', true);
70
-        $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
71
-
72
-        $ret = $this->converter->apply($request, $config);
73
-
74
-        $this->assertTrue($ret);
75
-        $this->assertNull($request->attributes->get('arg'));
76
-    }
77
-
78
-    /**
79
-     * @dataProvider idsProvider
80
-     */
81
-    public function testApplyWithId($id)
82
-    {
83
-        $request = new Request();
84
-        $request->attributes->set('id', $id);
85
-
86
-        $config = $this->createConfiguration('stdClass', array('id' => 'id'), 'arg');
87
-
88
-        $manager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
89
-        $objectRepository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
90
-        $this->registry->expects($this->once())
91
-              ->method('getManagerForClass')
92
-              ->with('stdClass')
93
-              ->will($this->returnValue($manager));
94
-
95
-        $manager->expects($this->once())
96
-            ->method('getRepository')
97
-            ->with('stdClass')
98
-            ->will($this->returnValue($objectRepository));
99
-
100
-        $objectRepository->expects($this->once())
101
-                      ->method('find')
102
-                      ->with($this->equalTo($id))
103
-                      ->will($this->returnValue($object =new \stdClass));
104
-
105
-        $ret = $this->converter->apply($request, $config);
106
-
107
-        $this->assertTrue($ret);
108
-        $this->assertSame($object, $request->attributes->get('arg'));
109
-    }
110
-
111
-    public function idsProvider()
112
-    {
113
-        return array(
114
-            array(1),
115
-            array(0),
116
-            array('foo'),
117
-        );
118
-    }
119
-
120
-    public function testApplyWithMappingAndExclude()
121
-    {
122
-        $request = new Request();
123
-        $request->attributes->set('foo', 1);
124
-        $request->attributes->set('bar', 2);
125
-
126
-        $config = $this->createConfiguration(
127
-            'stdClass',
128
-            array('mapping' => array('foo' => 'Foo'), 'exclude' => array('bar')),
129
-            'arg'
130
-        );
131
-
132
-        $manager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
133
-        $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
134
-        $repository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
135
-
136
-        $this->registry->expects($this->once())
137
-                ->method('getManagerForClass')
138
-                ->with('stdClass')
139
-                ->will($this->returnValue($manager));
140
-
141
-        $manager->expects($this->once())
142
-                ->method('getClassMetadata')
143
-                ->with('stdClass')
144
-                ->will($this->returnValue($metadata));
145
-        $manager->expects($this->once())
146
-                ->method('getRepository')
147
-                ->with('stdClass')
148
-                ->will($this->returnValue($repository));
149
-
150
-        $metadata->expects($this->once())
151
-                 ->method('hasField')
152
-                 ->with($this->equalTo('Foo'))
153
-                 ->will($this->returnValue(true));
154
-
155
-        $repository->expects($this->once())
156
-                      ->method('findOneBy')
157
-                      ->with($this->equalTo(array('Foo' => 1)))
158
-                      ->will($this->returnValue($object =new \stdClass));
159
-
160
-        $ret = $this->converter->apply($request, $config);
161
-
162
-        $this->assertTrue($ret);
163
-        $this->assertSame($object, $request->attributes->get('arg'));
164
-    }
165
-
166
-    public function testSupports()
167
-    {
168
-        $config = $this->createConfiguration('stdClass', array());
169
-        $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory');
170
-        $metadataFactory->expects($this->once())
171
-                        ->method('isTransient')
172
-                        ->with($this->equalTo('stdClass'))
173
-                        ->will($this->returnValue( false ));
174
-
175
-        $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
176
-        $objectManager->expects($this->once())
177
-                      ->method('getMetadataFactory')
178
-                      ->will($this->returnValue($metadataFactory));
179
-
180
-        $this->registry->expects($this->once())
181
-                    ->method('getManagers')
182
-                    ->will($this->returnValue(array($objectManager)));
183
-
184
-        $this->registry->expects($this->once())
185
-                      ->method('getManagerForClass')
186
-                      ->with('stdClass')
187
-                      ->will($this->returnValue($objectManager));
188
-
189
-        $ret = $this->converter->supports($config);
190
-
191
-        $this->assertTrue($ret, "Should be supported");
192
-    }
193
-
194
-    public function testSupportsWithConfiguredEntityManager()
195
-    {
196
-        $config = $this->createConfiguration('stdClass', array('entity_manager' => 'foo'));
197
-        $metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory');
198
-        $metadataFactory->expects($this->once())
199
-                        ->method('isTransient')
200
-                        ->with($this->equalTo('stdClass'))
201
-                        ->will($this->returnValue( false ));
202
-
203
-        $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
204
-        $objectManager->expects($this->once())
205
-                      ->method('getMetadataFactory')
206
-                      ->will($this->returnValue($metadataFactory));
207
-
208
-        $this->registry->expects($this->once())
209
-                    ->method('getManagers')
210
-                    ->will($this->returnValue(array($objectManager)));
211
-
212
-        $this->registry->expects($this->once())
213
-                      ->method('getManager')
214
-                      ->with('foo')
215
-                      ->will($this->returnValue($objectManager));
216
-
217
-        $ret = $this->converter->supports($config);
218
-
219
-        $this->assertTrue($ret, "Should be supported");
220
-    }
221
-}

+ 0 - 27
vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/composer.json View File

@@ -1,27 +0,0 @@
1
-{
2
-    "name": "sensio/framework-extra-bundle",
3
-    "description": "This bundle provides a way to configure your controllers with annotations",
4
-    "keywords": ["annotations","controllers"],
5
-    "type": "symfony-bundle",
6
-    "license": "MIT",
7
-    "authors": [
8
-        {
9
-            "name": "Fabien Potencier",
10
-            "email": "fabien@symfony.com"
11
-        }
12
-    ],
13
-    "require": {
14
-        "symfony/framework-bundle": "2.1.*",
15
-        "doctrine/common": ">=2.1,<2.5-dev"
16
-    },
17
-    "autoload": {
18
-        "psr-0": { "Sensio\\Bundle\\FrameworkExtraBundle": "" }
19
-    },
20
-    "target-dir": "Sensio/Bundle/FrameworkExtraBundle",
21
-    "extra": {
22
-        "branch-alias": {
23
-            "dev-master": "2.1.x-dev"
24
-        }
25
-    },
26
-    "minimum-stability": "dev"
27
-}

+ 0 - 59
vendor/sonata-project/exporter/lib/Exporter/Handler.php View File

@@ -1,59 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter;
13
-
14
-use Exporter\Source\SourceIteratorInterface;
15
-use Exporter\Writer\WriterInterface;
16
-
17
-class Handler
18
-{
19
-    protected $source;
20
-
21
-    protected $writer;
22
-
23
-    /**
24
-     * @param Source\SourceIteratorInterface $source
25
-     * @param Writer\WriterInterface         $writer
26
-     */
27
-    public function __construct(SourceIteratorInterface $source, WriterInterface $writer)
28
-    {
29
-        $this->source = $source;
30
-        $this->writer = $writer;
31
-    }
32
-
33
-    /**
34
-     * @return void
35
-     */
36
-    public function export()
37
-    {
38
-        $this->writer->open();
39
-
40
-        foreach ($this->source as $data) {
41
-            $this->writer->write($data);
42
-        }
43
-
44
-        $this->writer->close();
45
-    }
46
-
47
-    /**
48
-     * @static
49
-     *
50
-     * @param Source\SourceIteratorInterface $source
51
-     * @param Writer\WriterInterface         $writer
52
-     *
53
-     * @return Handler
54
-     */
55
-    public static function create(SourceIteratorInterface $source, WriterInterface $writer)
56
-    {
57
-        return new self($source, $writer);
58
-    }
59
-}

+ 0 - 25
vendor/sonata-project/exporter/lib/Exporter/Source/ArraySourceIterator.php View File

@@ -1,25 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-class ArraySourceIterator extends IteratorSourceIterator
15
-{
16
-    protected $iterator;
17
-
18
-    /**
19
-     * @param array $data
20
-     */
21
-    public function __construct(array $data)
22
-    {
23
-        parent::__construct(new \ArrayIterator($data));
24
-    }
25
-}

+ 0 - 91
vendor/sonata-project/exporter/lib/Exporter/Source/ChainSourceIterator.php View File

@@ -1,91 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-use ArrayIterator;
15
-
16
-class ChainSourceIterator implements SourceIteratorInterface
17
-{
18
-    protected $sources;
19
-
20
-    /**
21
-     * @param array $sources
22
-     */
23
-    public function __construct(array $sources = array())
24
-    {
25
-        $this->sources = new ArrayIterator();
26
-
27
-        foreach ($sources as $source) {
28
-            $this->addSource($source);
29
-        }
30
-    }
31
-
32
-    /**
33
-     * @param SourceIteratorInterface $source
34
-     */
35
-    public function addSource(SourceIteratorInterface $source)
36
-    {
37
-        $this->sources->append($source);
38
-    }
39
-
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    public function current()
44
-    {
45
-        return $this->sources->current()->current();
46
-    }
47
-
48
-    /**
49
-     * {@inheritdoc}
50
-     */
51
-    public function next()
52
-    {
53
-        $this->sources->current()->next();
54
-    }
55
-
56
-    /**
57
-     * {@inheritdoc}
58
-     */
59
-    public function key()
60
-    {
61
-        return $this->sources->current()->key();
62
-    }
63
-
64
-    /**
65
-     * {@inheritdoc}
66
-     */
67
-    public function valid()
68
-    {
69
-        if (!$this->sources->current()->valid()) {
70
-            $this->sources->next();
71
-
72
-            if (!$this->sources->valid()) {
73
-                return false;
74
-            }
75
-
76
-            $this->sources->current()->rewind();
77
-        }
78
-
79
-        return true;
80
-    }
81
-
82
-    /**
83
-     * {@inheritdoc}
84
-     */
85
-    public function rewind()
86
-    {
87
-        if ($this->sources->current()) {
88
-            $this->sources->current()->rewind();
89
-        }
90
-    }
91
-}

+ 0 - 94
vendor/sonata-project/exporter/lib/Exporter/Source/DoctrineDBALConnectionSourceIterator.php View File

@@ -1,94 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-use Exporter\Exception\InvalidMethodCallException;
15
-use Doctrine\DBAL\Driver\Connection;
16
-use Doctrine\DBAL\Driver\Statement;
17
-
18
-class DoctrineDBALConnectionSourceIterator implements SourceIteratorInterface
19
-{
20
-    protected $connection;
21
-
22
-    protected $query;
23
-
24
-    protected $parameters;
25
-
26
-    protected $current;
27
-
28
-    protected $position;
29
-
30
-    /**
31
-     * @var Statement
32
-     */
33
-    protected $statement;
34
-
35
-    /**
36
-     * @param Connection $statement
37
-     */
38
-    public function __construct(Connection $connection, $query, array $parameters = array())
39
-    {
40
-        $this->connection = $connection;
41
-        $this->query      = $query;
42
-        $this->parameters = $parameters;
43
-
44
-        $this->position   = 0;
45
-    }
46
-
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function current()
51
-    {
52
-        return $this->current;
53
-    }
54
-
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function next()
59
-    {
60
-        $this->current = $this->statement->fetch(\PDO::FETCH_ASSOC);
61
-        $this->position++;
62
-    }
63
-
64
-    /**
65
-     * {@inheritdoc}
66
-     */
67
-    public function key()
68
-    {
69
-        return $this->position;
70
-    }
71
-
72
-    /**
73
-     * {@inheritdoc}
74
-     */
75
-    public function valid()
76
-    {
77
-        return is_array($this->current);
78
-    }
79
-
80
-    /**
81
-     * {@inheritdoc}
82
-     */
83
-    public function rewind()
84
-    {
85
-        if ($this->statement) {
86
-            throw new InvalidMethodCallException('Cannot rewind a PDOStatement');
87
-        }
88
-
89
-        $this->statement = $this->connection->prepare($this->query);
90
-        $this->statement->execute($this->parameters);
91
-
92
-        $this->next();
93
-    }
94
-}

+ 0 - 123
vendor/sonata-project/exporter/lib/Exporter/Source/DoctrineODMQuerySourceIterator.php View File

@@ -1,123 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-use Exporter\Exception\InvalidMethodCallException;
15
-use Doctrine\ODM\MongoDB\Query\Query;
16
-use Exporter\Source\SourceIteratorInterface;
17
-use Symfony\Component\Form\Util\PropertyPath;
18
-
19
-class DoctrineODMQuerySourceIterator implements SourceIteratorInterface
20
-{
21
-    /**
22
-     * @var \Doctrine\ORM\Query
23
-     */
24
-    protected $query;
25
-
26
-    /**
27
-     * @var \Doctrine\ORM\Internal\Hydration\IterableResult
28
-     */
29
-    protected $iterator;
30
-
31
-    protected $propertyPaths;
32
-
33
-    /**
34
-     * @param \Doctrine\ODM\MongoDB\Query\Query $query  The Doctrine Query
35
-     * @param array                             $fields Fields to export
36
-     */
37
-    public function __construct(Query $query, array $fields)
38
-    {
39
-        $this->query = clone $query;
40
-
41
-        $this->propertyPaths = array();
42
-        foreach ($fields as $name => $field) {
43
-            if (is_string($name) && is_string($field)) {
44
-                $this->propertyPaths[$name] = new PropertyPath($field);
45
-            } else {
46
-                $this->propertyPaths[$field] = new PropertyPath($field);
47
-            }
48
-        }
49
-    }
50
-
51
-    /**
52
-     * {@inheritdoc}
53
-     */
54
-    public function current()
55
-    {
56
-        $current = $this->iterator->current();
57
-
58
-        $data = array();
59
-
60
-        foreach ($this->propertyPaths as $name => $propertyPath) {
61
-            $data[$name] = $this->getValue($propertyPath->getValue($current));
62
-        }
63
-
64
-        $this->query->getDocumentManager()->getUnitOfWork()->detach($current);
65
-
66
-        return $data;
67
-    }
68
-
69
-    /**
70
-     * @param $value
71
-     *
72
-     * @return null|string
73
-     */
74
-    protected function getValue($value)
75
-    {
76
-        if (is_array($value) or $value instanceof \Traversable) {
77
-            $value = null;
78
-        } elseif ($value instanceof \DateTime) {
79
-            $value = $value->format('r');
80
-        } elseif (is_object($value)) {
81
-            $value = (string) $value;
82
-        }
83
-
84
-        return $value;
85
-    }
86
-
87
-    /**
88
-     * {@inheritdoc}
89
-     */
90
-    public function next()
91
-    {
92
-        $this->iterator->next();
93
-    }
94
-
95
-    /**
96
-     * {@inheritdoc}
97
-     */
98
-    public function key()
99
-    {
100
-        return $this->iterator->key();
101
-    }
102
-
103
-    /**
104
-     * {@inheritdoc}
105
-     */
106
-    public function valid()
107
-    {
108
-        return $this->iterator->valid();
109
-    }
110
-
111
-    /**
112
-     * {@inheritdoc}
113
-     */
114
-    public function rewind()
115
-    {
116
-        if ($this->iterator) {
117
-            throw new InvalidMethodCallException('Cannot rewind a Doctrine\ODM\Query');
118
-        }
119
-
120
-        $this->iterator = $this->query->iterate();
121
-        $this->iterator->rewind();
122
-    }
123
-}

+ 0 - 81
vendor/sonata-project/exporter/lib/Exporter/Source/PDOStatementSourceIterator.php View File

@@ -1,81 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-use Exporter\Exception\InvalidMethodCallException;
15
-
16
-class PDOStatementSourceIterator implements SourceIteratorInterface
17
-{
18
-    protected $statement;
19
-
20
-    protected $current;
21
-
22
-    protected $position;
23
-
24
-    protected $rewinded;
25
-
26
-    /**
27
-     * @param \PDOStatement $statement
28
-     */
29
-    public function __construct(\PDOStatement $statement)
30
-    {
31
-        $this->statement = $statement;
32
-        $this->position  = 0;
33
-        $this->rewinded  = false;
34
-    }
35
-
36
-    /**
37
-     * {@inheritdoc}
38
-     */
39
-    public function current()
40
-    {
41
-        return $this->current;
42
-    }
43
-
44
-    /**
45
-     * {@inheritdoc}
46
-     */
47
-    public function next()
48
-    {
49
-        $this->current = $this->statement->fetch(\PDO::FETCH_ASSOC);
50
-        $this->position++;
51
-    }
52
-
53
-    /**
54
-     * {@inheritdoc}
55
-     */
56
-    public function key()
57
-    {
58
-        return $this->position;
59
-    }
60
-
61
-    /**
62
-     * {@inheritdoc}
63
-     */
64
-    public function valid()
65
-    {
66
-        return is_array($this->current);
67
-    }
68
-
69
-    /**
70
-     * {@inheritdoc}
71
-     */
72
-    public function rewind()
73
-    {
74
-        if ($this->rewinded) {
75
-            throw new InvalidMethodCallException('Cannot rewind a PDOStatement');
76
-        }
77
-
78
-        $this->current  = $this->statement->fetch(\PDO::FETCH_ASSOC);
79
-        $this->rewinded = true;
80
-    }
81
-}

+ 0 - 17
vendor/sonata-project/exporter/lib/Exporter/Source/SourceIteratorInterface.php View File

@@ -1,17 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Source;
13
-
14
-interface SourceIteratorInterface extends \Iterator
15
-{
16
-
17
-}

+ 0 - 86
vendor/sonata-project/exporter/lib/Exporter/Source/SymfonySitemapSourceIterator.php View File

@@ -1,86 +0,0 @@
1
-<?php
2
-/*
3
- * This file is part of the Sonata project.
4
- *
5
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
-
11
-namespace Exporter\Source;
12
-
13
-use Symfony\Component\Routing\RouterInterface;
14
-
15
-class SymfonySitemapSourceIterator implements SourceIteratorInterface
16
-{
17
-    protected $router;
18
-
19
-    protected $source;
20
-
21
-    protected $routeName;
22
-
23
-    protected $parameters;
24
-
25
-    /**
26
-     * @param SourceIteratorInterface $source
27
-     * @param RouterInterface         $router
28
-     * @param string                  $routeName
29
-     * @param array                   $parameters
30
-     */
31
-    public function __construct(SourceIteratorInterface $source, RouterInterface $router, $routeName, array $parameters = array())
32
-    {
33
-        $this->source = $source;
34
-        $this->router = $router;
35
-        $this->routeName = $routeName;
36
-        $this->parameters = $parameters;
37
-    }
38
-
39
-    /**
40
-     * {@inheritdoc}
41
-     */
42
-    public function current()
43
-    {
44
-        $data = $this->source->current();
45
-
46
-        $parameters = array_merge($this->parameters, array_intersect_key($data, $this->parameters));
47
-
48
-        if (!isset($data['url'])) {
49
-            $data['url'] = $this->router->generate($this->routeName, $parameters, true);
50
-        }
51
-
52
-        return $data;
53
-    }
54
-
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function next()
59
-    {
60
-        $this->source->next();
61
-    }
62
-
63
-    /**
64
-     * {@inheritdoc}
65
-     */
66
-    public function key()
67
-    {
68
-        return $this->source->key();
69
-    }
70
-
71
-    /**
72
-     * {@inheritdoc}
73
-     */
74
-    public function valid()
75
-    {
76
-        return $this->source->valid();
77
-    }
78
-
79
-    /**
80
-     * {@inheritdoc}
81
-     */
82
-    public function rewind()
83
-    {
84
-        $this->source->rewind();
85
-    }
86
-}

+ 0 - 155
vendor/sonata-project/exporter/lib/Exporter/Writer/GsaFeedWriter.php View File

@@ -1,155 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-/**
15
- * Generates a GSA feed.
16
- *
17
- * @author Rémi Marseille <marseille@ekino.com>
18
- */
19
-class GsaFeedWriter implements WriterInterface
20
-{
21
-    const LIMIT_SIZE = 31457280; // 30MB
22
-
23
-    /**
24
-     * @var \SplFileInfo
25
-     */
26
-    private $folder;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    private $dtd;
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    private $datasource;
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    private $feedtype;
42
-
43
-    /**
44
-     * @var integer
45
-     */
46
-    private $bufferPart;
47
-
48
-    /**
49
-     * @var resource
50
-     */
51
-    private $buffer;
52
-
53
-    /**
54
-     * @var integer
55
-     */
56
-    private $bufferSize;
57
-
58
-    /**
59
-     * Constructor
60
-     *
61
-     * @param \SplFileInfo $folder     The folder to store the generated feed(s)
62
-     * @param string       $dtd        A DTD URL (something like http://gsa.example.com/gsafeed.dtd)
63
-     * @param string       $datasource A datasouce
64
-     * @param string       $feedtype   A feedtype (full|incremental|metadata-and-url)
65
-     */
66
-    public function __construct(\SplFileInfo $folder, $dtd, $datasource, $feedtype)
67
-    {
68
-        $this->folder = $folder;
69
-        $this->dtd = $dtd;
70
-        $this->datasource = $datasource;
71
-        $this->feedtype = $feedtype;
72
-        $this->bufferPart = 0;
73
-        $this->bufferSize = 0;
74
-    }
75
-
76
-    /**
77
-     * {@inheritdoc}
78
-     */
79
-    public function open()
80
-    {
81
-        $this->generateNewPart();
82
-    }
83
-
84
-    /**
85
-     * {@inheritdoc}
86
-     */
87
-    public function write(array $data)
88
-    {
89
-        $line = sprintf("    <record url=\"%s\" mimetype=\"%s\" action=\"%s\"/>\n",
90
-            $data['url'],
91
-            $data['mime_type'],
92
-            $data['action']
93
-        );
94
-
95
-        // + 10 corresponding to the length of the closing tag
96
-        if (($this->bufferSize + strlen($line) + 10) > self::LIMIT_SIZE) {
97
-            $this->generateNewPart();
98
-        }
99
-
100
-        $this->bufferSize += fwrite($this->buffer, $line);
101
-    }
102
-
103
-    /**
104
-     * {@inheritdoc}
105
-     */
106
-    public function close()
107
-    {
108
-        if ($this->buffer) {
109
-            $this->closeFeed();
110
-        }
111
-    }
112
-
113
-    /**
114
-     * Generates a new file
115
-     *
116
-     * @throws \RuntimeException
117
-     */
118
-    private function generateNewPart()
119
-    {
120
-        if ($this->buffer) {
121
-            $this->closeFeed();
122
-        }
123
-
124
-        $this->bufferSize = 0;
125
-        $this->bufferPart++;
126
-
127
-        if (!is_writable($this->folder)) {
128
-            throw new \RuntimeException(sprintf('Unable to write to folder: %s', $this->folder));
129
-        }
130
-
131
-        $this->buffer = fopen(sprintf('%s/feed_%05d.xml', $this->folder, $this->bufferPart), 'w');
132
-
133
-        $this->bufferSize += fwrite($this->buffer, <<<XML
134
-<?xml version="1.0" encoding="UTF-8"?>
135
-<!DOCTYPE gsafeed PUBLIC "-//Google//DTD GSA Feeds//EN" "$this->dtd">
136
-<gsafeed>
137
-    <header>
138
-        <datasource>$this->datasource</datasource>
139
-        <feedtype>$this->feedtype</feedtype>
140
-    </header>
141
-
142
-XML
143
-        );
144
-    }
145
-
146
-    /**
147
-     * Closes the current feed
148
-     */
149
-    private function closeFeed()
150
-    {
151
-        fwrite($this->buffer, '</gsafeed>');
152
-
153
-        fclose($this->buffer);
154
-    }
155
-}

+ 0 - 49
vendor/sonata-project/exporter/lib/Exporter/Writer/InMemoryWriter.php View File

@@ -1,49 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-class InMemoryWriter implements WriterInterface
15
-{
16
-    protected $elements;
17
-
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function open()
22
-    {
23
-        $this->elements = array();
24
-    }
25
-
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    public function close()
30
-    {
31
-        return $this->elements;
32
-    }
33
-
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    public function write(array $data)
38
-    {
39
-        $this->elements[] = $data;
40
-    }
41
-
42
-    /**
43
-     * @return array
44
-     */
45
-    public function getElements()
46
-    {
47
-        return $this->elements;
48
-    }
49
-}

+ 0 - 367
vendor/sonata-project/exporter/lib/Exporter/Writer/SitemapWriter.php View File

@@ -1,367 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-/**
15
- * Generates a sitemap site from
16
- */
17
-class SitemapWriter implements WriterInterface
18
-{
19
-    const LIMIT_SIZE = 10485760;
20
-    const LIMIT_URL  = 50000;
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    protected $folder;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $pattern;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    protected $groupName;
36
-
37
-    /**
38
-     * @var boolean
39
-     */
40
-    protected $autoIndex;
41
-
42
-    /**
43
-     * @var resource
44
-     */
45
-    protected $buffer;
46
-
47
-    /**
48
-     * @var array
49
-     */
50
-    protected $headers;
51
-
52
-    /**
53
-     * @var integer
54
-     */
55
-    protected $bufferSize = 0;
56
-
57
-    /**
58
-     * @var integer
59
-     */
60
-    protected $bufferUrlCount = 0;
61
-
62
-    /**
63
-     * @var integer
64
-     */
65
-    protected $bufferPart = 0;
66
-
67
-    /**
68
-     * Constructor.
69
-     *
70
-     * @param string  $folder    The folder to store the sitemap.xml file
71
-     * @param mixed   $groupName Name of sub-sitemap (optional)
72
-     * @param array   $headers   Indicate the need for namespace in the header sitemap
73
-     * @param boolean $autoIndex If you want to generate index of sitemap (optional)
74
-     */
75
-    public function __construct($folder, $groupName = false, array $headers = array(), $autoIndex = true)
76
-    {
77
-        $this->folder    = $folder;
78
-        $this->groupName = is_string($groupName) ? $groupName : '';
79
-        $this->headers   = $headers;
80
-        $this->autoIndex = $autoIndex;
81
-
82
-        $this->pattern = 'sitemap_' . ($this->groupName? $this->groupName . '_' : '') . '%05d.xml';
83
-    }
84
-
85
-    /**
86
-     * Returns the status of auto generation of index site map
87
-     *
88
-     * @return boolean
89
-     */
90
-    public function isAutoIndex()
91
-    {
92
-        return $this->autoIndex;
93
-    }
94
-
95
-    /**
96
-     * Returns folder to store the sitemap.xml file
97
-     *
98
-     * @return string
99
-     */
100
-    public function getFolder()
101
-    {
102
-        return $this->folder;
103
-    }
104
-
105
-    /**
106
-     * {@inheritdoc}
107
-     */
108
-    public function open()
109
-    {
110
-        $this->bufferPart = 0;
111
-        $this->generateNewPart();
112
-    }
113
-
114
-    /**
115
-     * {@inheritdoc}
116
-     */
117
-    public function write(array $data)
118
-    {
119
-        $data = $this->buildData($data);
120
-
121
-        switch ($data['type']) {
122
-            case 'video':
123
-                $line = $this->generateVideoLine($data);
124
-                break;
125
-
126
-            case 'image':
127
-                $line = $this->generateImageLine($data);
128
-                break;
129
-
130
-            case 'default':
131
-            default:
132
-                $line = $this->generateDefaultLine($data);
133
-        }
134
-
135
-        $this->addSitemapLine($line);
136
-    }
137
-
138
-    /**
139
-     * {@inheritdoc}
140
-     */
141
-    public function close()
142
-    {
143
-        if ($this->buffer) {
144
-            $this->closeSitemap();
145
-        }
146
-
147
-        if ($this->autoIndex) {
148
-            self::generateSitemapIndex(
149
-                $this->folder,
150
-                'sitemap_' . ($this->groupName ? $this->groupName . '_' : '') . '*.xml',
151
-                'sitemap' . ($this->groupName ? '_' . $this->groupName : '') . '.xml'
152
-            );
153
-        }
154
-    }
155
-
156
-    /**
157
-     * Generates the sitemap index from the sitemap part avaible in the folder
158
-     *
159
-     * @param string $folder
160
-     * @param string $pattern
161
-     * @param string $filename
162
-     */
163
-    public static function generateSitemapIndex($folder, $pattern = 'sitemap*.xml', $filename = 'sitemap.xml')
164
-    {
165
-        $content = "<?xml version='1.0' encoding='UTF-8'?" . ">\n<sitemapindex xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.sitemaps.org/schemas/sitemap/1.0 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd' xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>\n";
166
-        foreach (glob(sprintf('%s/%s', $folder, $pattern)) as $file) {
167
-            $stat = stat($file);
168
-            $content .= sprintf("\t" . '<sitemap><loc>%s</loc><lastmod>%s</lastmod></sitemap>' . "\n",
169
-                basename($file),
170
-                date('Y-m-d', $stat['mtime'])
171
-            );
172
-        }
173
-
174
-        $content .= '</sitemapindex>';
175
-
176
-        file_put_contents(sprintf('%s/%s', $folder, $filename), $content);
177
-    }
178
-
179
-    /**
180
-     * Generate a new sitemap part
181
-     *
182
-     * @throws \RuntimeException
183
-     */
184
-    protected function generateNewPart()
185
-    {
186
-        if ($this->buffer) {
187
-            $this->closeSitemap();
188
-        }
189
-
190
-        $this->bufferUrlCount = 0;
191
-        $this->bufferSize     = 0;
192
-        $this->bufferPart++;
193
-
194
-        if (!is_writable($this->folder)) {
195
-            throw new \RuntimeException(sprintf('Unable to write to folder: %s', $this->folder));
196
-        }
197
-
198
-        $filename = sprintf($this->pattern, $this->bufferPart);
199
-
200
-        $this->buffer = fopen($this->folder . '/' . $filename, 'w');
201
-
202
-        $this->bufferSize += fwrite($this->buffer, '<?xml version="1.0" encoding="UTF-8"?>'."\n".'<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . $this->getHeaderByFlag() . '>'."\n");
203
-    }
204
-
205
-    /**
206
-     * Add a new line into the sitemap part
207
-     *
208
-     * @param string $line
209
-     */
210
-    protected function addSitemapLine($line)
211
-    {
212
-        if ($this->bufferUrlCount >= self::LIMIT_URL) {
213
-            $this->generateNewPart();
214
-        }
215
-
216
-        if (($this->bufferSize + strlen($line) + 9) > self::LIMIT_SIZE) {
217
-            $this->generateNewPart();
218
-        }
219
-
220
-        $this->bufferUrlCount++;
221
-
222
-        $this->bufferSize += fwrite($this->buffer, $line);
223
-    }
224
-
225
-    /**
226
-     * Build data with default parameters
227
-     *
228
-     * @param array $data List of parameters
229
-     *
230
-     * @return array
231
-     */
232
-    protected function buildData(array $data)
233
-    {
234
-        $default = array(
235
-            'url'        => null,
236
-            'lastmod'    => 'now',
237
-            'changefreq' => 'weekly',
238
-            'priority'   => 0.5,
239
-            'type'       => 'default'
240
-        );
241
-
242
-        $data = array_merge($default, $data);
243
-
244
-        $this->fixDataType($data);
245
-
246
-        return $data;
247
-    }
248
-
249
-    /**
250
-     * Fix type of data, if data type is specific,
251
-     * he must to be defined in data and he must to be a array
252
-     *
253
-     * @param array &$data List of parameters
254
-     *
255
-     * @return void
256
-     */
257
-    protected function fixDataType(array &$data)
258
-    {
259
-        if ('default' === $data['type']) {
260
-            return;
261
-        }
262
-
263
-        $valid_var_name = array(
264
-            'image' => 'images',
265
-            'video' => 'video'
266
-        );
267
-
268
-        if (!isset($valid_var_name[$data['type']], $data[$valid_var_name[$data['type']]]) || !is_array($data[$valid_var_name[$data['type']]])) {
269
-            $data['type'] = 'default';
270
-        }
271
-    }
272
-
273
-    /**
274
-     * Generate standard line of sitemap
275
-     *
276
-     * @param array $data List of parameters
277
-     *
278
-     * @return string
279
-     */
280
-    protected function generateDefaultLine(array $data)
281
-    {
282
-        return sprintf("    ".'<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%s</priority></url>'."\n", $data['url'], date('Y-m-d', strtotime($data['lastmod'])), $data['changefreq'], $data['priority']);
283
-    }
284
-
285
-    /**
286
-     * Generate image line of sitemap
287
-     *
288
-     * @param array $data List of parameters
289
-     *
290
-     * @return string
291
-     */
292
-    protected function generateImageLine(array $data)
293
-    {
294
-        $images = '';
295
-
296
-        if (count($data['images']) > 1000) {
297
-            $data['images'] = array_splice($data['images'], 1000);
298
-        }
299
-
300
-        $builder = array(
301
-            'url'      => 'loc',
302
-            'location' => 'geo_location',
303
-        );
304
-
305
-        foreach ($data['images'] as $image) {
306
-            $images .= '<image:image>';
307
-
308
-            foreach ($image as $key => $element) {
309
-                $images .= sprintf('<image:%1$s>%2$s</image:%1$s>', (isset($builder[$key]) ? $builder[$key] : $key), $element);
310
-            }
311
-
312
-            $images .= '</image:image>';
313
-        }
314
-
315
-        return sprintf("    ".'<url><loc>%s</loc>%s</url>'."\n", $data['url'], $images);
316
-    }
317
-
318
-    /**
319
-     * Generate video line of sitemap
320
-     *
321
-     * @param array $data List of parameters
322
-     *
323
-     * @return string
324
-     */
325
-    protected function generateVideoLine(array $data)
326
-    {
327
-        $videos  = '';
328
-        $builder = array(
329
-            'thumbnail' => 'thumbnail_loc'
330
-        );
331
-
332
-        foreach ($data['video'] as $key => $video) {
333
-            $videos .= sprintf('<video:%1$s>%2$s</video:%1$s>', (isset($builder[$key]) ? $builder[$key] : $key), $video);
334
-        }
335
-
336
-        return sprintf("    ".'<url><loc>%s</loc><video:video>%s</video:video></url>'."\n", $data['url'], $videos);
337
-    }
338
-
339
-    /**
340
-     * Generate additional header with namespace adapted to the content
341
-     *
342
-     * @return string
343
-     */
344
-    protected function getHeaderByFlag()
345
-    {
346
-        $namespaces = array(
347
-            'video' => 'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"',
348
-            'image' => 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'
349
-        );
350
-
351
-        $result = '';
352
-        foreach ($this->headers as $flag) {
353
-            $result .= ' ' . $namespaces[$flag];
354
-        }
355
-
356
-        return $result;
357
-    }
358
-
359
-    /**
360
-     * Close the sitemap part
361
-     */
362
-    protected function closeSitemap()
363
-    {
364
-        fwrite($this->buffer, '</urlset>');
365
-        fclose($this->buffer);
366
-    }
367
-}

+ 0 - 32
vendor/sonata-project/exporter/lib/Exporter/Writer/WriterInterface.php View File

@@ -1,32 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-interface WriterInterface
15
-{
16
-    /**
17
-     * @return void
18
-     */
19
-    public function open();
20
-
21
-    /**
22
-     * @param array $data
23
-     *
24
-     * @return void
25
-     */
26
-    public function write(array $data);
27
-
28
-    /**
29
-     * @return void
30
-     */
31
-    public function close();
32
-}

+ 0 - 95
vendor/sonata-project/exporter/lib/Exporter/Writer/XlsWriter.php View File

@@ -1,95 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-class XlsWriter implements WriterInterface
15
-{
16
-    protected $filename;
17
-
18
-    protected $file;
19
-
20
-    protected $showHeaders;
21
-
22
-    protected $position;
23
-
24
-    /**
25
-     * @throws \RuntimeException
26
-     *
27
-     * @param      $filename
28
-     * @param bool $showHeaders
29
-     */
30
-    public function __construct($filename, $showHeaders = true)
31
-    {
32
-        $this->filename    = $filename;
33
-        $this->showHeaders = $showHeaders;
34
-        $this->position    = 0;
35
-
36
-        if (is_file($filename)) {
37
-            throw new \RuntimeException(sprintf('The file %s already exist', $filename));
38
-        }
39
-    }
40
-
41
-    /**
42
-     * {@inheritdoc}
43
-     */
44
-    public function open()
45
-    {
46
-        $this->file = fopen($this->filename, 'w', false);
47
-        fwrite($this->file, "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><meta name=ProgId content=Excel.Sheet><meta name=Generator content=\"https://github.com/sonata-project/exporter\"></head><body><table>");
48
-    }
49
-
50
-    /**
51
-     * {@inheritdoc}
52
-     */
53
-    public function close()
54
-    {
55
-        fwrite($this->file, "</table></body></html>");
56
-        fclose($this->file);
57
-    }
58
-
59
-    /**
60
-     * {@inheritdoc}
61
-     */
62
-    public function write(array $data)
63
-    {
64
-        $this->init($data);
65
-
66
-        fwrite($this->file, '<tr>');
67
-        foreach ($data as $value) {
68
-            fwrite($this->file, sprintf('<td>%s</td>', $value));
69
-        }
70
-        fwrite($this->file, '</tr>');
71
-
72
-        $this->position++;
73
-    }
74
-
75
-    /**
76
-     * @param $data
77
-     *
78
-     * @return array mixed
79
-     */
80
-    protected function init($data)
81
-    {
82
-        if ($this->position > 0) {
83
-            return;
84
-        }
85
-
86
-        if ($this->showHeaders) {
87
-            fwrite($this->file, '<tr>');
88
-            foreach ($data as $header => $value) {
89
-                fwrite($this->file, sprintf('<th>%s</th>', $header));
90
-            }
91
-            fwrite($this->file, '</tr>');
92
-            $this->position++;
93
-        }
94
-    }
95
-}

+ 0 - 95
vendor/sonata-project/exporter/lib/Exporter/Writer/XmlWriter.php View File

@@ -1,95 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Sonata package.
5
- *
6
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Exporter\Writer;
13
-
14
-use Exporter\Exception\InvalidDataFormatException;
15
-
16
-class XmlWriter implements WriterInterface
17
-{
18
-    protected $filename;
19
-
20
-    protected $file;
21
-
22
-    protected $position;
23
-
24
-    protected $mainElement;
25
-
26
-    protected $childElement;
27
-
28
-    /**
29
-     * @param string $filename
30
-     * @param string $mainElement
31
-     * @param string $childElement
32
-     */
33
-    public function __construct($filename, $mainElement = 'datas', $childElement = 'data')
34
-    {
35
-        $this->filename     = $filename;
36
-        $this->position     = 0;
37
-        $this->mainElement  = $mainElement;
38
-        $this->childElement = $childElement;
39
-
40
-        if (is_file($filename)) {
41
-            throw new \RuntimeException(sprintf('The file %s already exist', $filename));
42
-        }
43
-    }
44
-
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    public function open()
49
-    {
50
-        $this->file = fopen($this->filename, 'w', false);
51
-
52
-        fwrite($this->file, sprintf("<?xml version=\"1.0\" ?>\n<%s>\n", $this->mainElement));
53
-    }
54
-
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function close()
59
-    {
60
-        fwrite($this->file, sprintf("</%s>", $this->mainElement));
61
-
62
-        fclose($this->file);
63
-    }
64
-
65
-    /**
66
-     * {@inheritdoc}
67
-     */
68
-    public function write(array $data)
69
-    {
70
-        fwrite($this->file, sprintf("<%s>\n", $this->childElement));
71
-
72
-        foreach ($data as $k => $v) {
73
-            $this->generateNode($k, $v);
74
-        }
75
-
76
-        fwrite($this->file, sprintf("</%s>\n", $this->childElement));
77
-    }
78
-
79
-    /**
80
-     * @param string $name
81
-     * @param string $value
82
-     *
83
-     * @return void
84
-     */
85
-    protected function generateNode($name, $value)
86
-    {
87
-        if (is_array($value)) {
88
-            throw new \RuntimeException('Not implemented');
89
-        } elseif (is_scalar($value) || is_null($value)) {
90
-            fwrite($this->file, sprintf("<%s><![CDATA[%s]]></%s>\n", $name, $value, $name));
91
-        } else {
92
-            throw new InvalidDataFormatException('Invalid data');
93
-        }
94
-    }
95
-}

+ 0 - 20
vendor/sonata-project/exporter/test/Exporter/Test/Source/ChainSourceIteratorTest.php View File

@@ -1,20 +0,0 @@
1
-<?php
2
-
3
-namespace Exporter\Test\Source;
4
-
5
-use Exporter\Source\ChainSourceIterator;
6
-
7
-class ChainSourceIteratorTest extends \PHPUnit_Framework_TestCase
8
-{
9
-
10
-    public function testIterator()
11
-    {
12
-        $source = $this->getMock('Exporter\Source\SourceIteratorInterface');
13
-
14
-        $iterator = new ChainSourceIterator(array($source));
15
-
16
-        foreach ($iterator as $data) {
17
-
18
-        }
19
-    }
20
-}

+ 0 - 161
vendor/sonata-project/exporter/test/Exporter/Test/Writer/GsaFeedWriterTest.php View File

@@ -1,161 +0,0 @@
1
-<?php
2
-
3
-namespace Exporter\Test\Source;
4
-
5
-use Exporter\Writer\GsaFeedWriter;
6
-
7
-/**
8
- * Tests the GSA feed writer class
9
- *
10
- * @author Rémi Marseille <marseille@ekino.com>
11
- */
12
-class GsaFeedWriterTest extends \PHPUnit_Framework_TestCase
13
-{
14
-    /**
15
-     * @var \SplFileInfo
16
-     */
17
-    private $folder;
18
-
19
-    /**
20
-     * @var string
21
-     */
22
-    private $dtd;
23
-
24
-    /**
25
-     * @var string
26
-     */
27
-    private $datasource;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    private $feedtype;
33
-
34
-    /**
35
-     * Creates the folder useful to this test
36
-     */
37
-    public function setUp()
38
-    {
39
-        $path = sys_get_temp_dir().'/sonata_exporter_test';
40
-        $this->folder = new \SplFileInfo($path);
41
-
42
-        $this->tearDown();
43
-
44
-        mkdir($path);
45
-
46
-        $this->dtd = 'http://gsa.example.com/gsafeed.dtd';
47
-        $this->datasource = 'default_collection';
48
-        $this->feedtype = 'metadata-and-url';
49
-    }
50
-
51
-    /**
52
-     * @expectedException RuntimeException
53
-     */
54
-    public function testNonExistentFolder()
55
-    {
56
-        $writer = new GsaFeedWriter(new \SplFileInfo('foo'), $this->dtd, $this->datasource, $this->feedtype);
57
-        $writer->open();
58
-    }
59
-
60
-    /**
61
-     * Tests a simple write case
62
-     */
63
-    public function testSimpleWrite()
64
-    {
65
-        $writer = new GsaFeedWriter($this->folder, $this->dtd, $this->datasource, $this->feedtype);
66
-        $writer->open();
67
-        $writer->write(array(
68
-            'url'       => 'http://sonata-project.org/about',
69
-            'mime_type' => 'text/html',
70
-            'action'    => 'add',
71
-        ));
72
-        $writer->write(array(
73
-            'url'       => 'http://sonata-project.org/bundles/',
74
-            'mime_type' => 'text/html',
75
-            'action'    => 'delete',
76
-        ));
77
-        $writer->close();
78
-
79
-        $generatedFiles = $this->getFiles();
80
-
81
-        $this->assertCount(1, $generatedFiles);
82
-        $this->assertEquals($this->folder . '/feed_00001.xml', $generatedFiles[0]);
83
-
84
-        // this will throw an exception if the xml is invalid
85
-        new \SimpleXMLElement(file_get_contents($generatedFiles[0]));
86
-
87
-        $expected = <<<XML
88
-<?xml version="1.0" encoding="UTF-8"?>
89
-<!DOCTYPE gsafeed PUBLIC "-//Google//DTD GSA Feeds//EN" "$this->dtd">
90
-<gsafeed>
91
-    <header>
92
-        <datasource>$this->datasource</datasource>
93
-        <feedtype>$this->feedtype</feedtype>
94
-    </header>
95
-    <record url="http://sonata-project.org/about" mimetype="text/html" action="add"/>
96
-    <record url="http://sonata-project.org/bundles/" mimetype="text/html" action="delete"/>
97
-</gsafeed>
98
-XML;
99
-
100
-        $this->assertEquals(trim($expected), file_get_contents($generatedFiles[0]));
101
-    }
102
-
103
-    /**
104
-     * Tests the writer limit
105
-     */
106
-    public function testLimitSize()
107
-    {
108
-        $writer = new GsaFeedWriter($this->folder, $this->dtd, $this->datasource, $this->feedtype);
109
-        $writer->open();
110
-
111
-        foreach (range(0, GsaFeedWriter::LIMIT_SIZE / 8196) as $i) {
112
-            $writer->write(array(
113
-                'url'       => str_repeat('x', 8196),
114
-                'mime_type' => 'text/html',
115
-                'action'    => 'add',
116
-            ));
117
-        }
118
-
119
-        $writer->close();
120
-
121
-        $generatedFiles = $this->getFiles();
122
-
123
-        $this->assertCount(2, $generatedFiles);
124
-
125
-        // this will throw an exception if the xml is invalid
126
-        new \SimpleXMLElement(file_get_contents($generatedFiles[0]));
127
-        new \SimpleXMLElement(file_get_contents($generatedFiles[1]));
128
-
129
-        $info = stat($generatedFiles[0]);
130
-
131
-        $this->assertLessThan(GsaFeedWriter::LIMIT_SIZE, $info['size']);
132
-    }
133
-
134
-    /**
135
-     * Gets an array of files of the main folder
136
-     *
137
-     * @return array
138
-     */
139
-    public function getFiles()
140
-    {
141
-        $files = glob($this->folder->getRealPath().'/*.xml');
142
-
143
-        sort($files);
144
-
145
-        return $files;
146
-    }
147
-
148
-    /**
149
-     * Deletes the generated XML and the created folder
150
-     */
151
-    public function tearDown()
152
-    {
153
-        if ($this->folder->getRealPath()) {
154
-            foreach ($this->getFiles() as $file) {
155
-                unlink($file);
156
-            }
157
-
158
-            rmdir($this->folder->getRealPath());
159
-        }
160
-    }
161
-}

+ 0 - 185
vendor/sonata-project/exporter/test/Exporter/Test/Writer/SitemapWriterTest.php View File

@@ -1,185 +0,0 @@
1
-<?php
2
-
3
-namespace Exporter\Test\Source;
4
-
5
-use Exporter\Writer\SitemapWriter;
6
-use SimpleXMLElement;
7
-
8
-class SitemapWriterTest extends \PHPUnit_Framework_TestCase
9
-{
10
-    protected $folder;
11
-
12
-    public function setUp()
13
-    {
14
-        $this->folder = sys_get_temp_dir().'/sonata_exporter_test';
15
-
16
-        $this->tearDown();
17
-
18
-        mkdir($this->folder);
19
-    }
20
-
21
-    /**
22
-     * @expectedException RuntimeException
23
-     */
24
-    public function testNonExistentFolder()
25
-    {
26
-        $writer = new SitemapWriter('booo');
27
-        $writer->open();
28
-    }
29
-
30
-    public function testSimpleWrite()
31
-    {
32
-        $writer = new SitemapWriter($this->folder);
33
-        $writer->open();
34
-        $writer->write(array(
35
-            'url'     => 'http://sonata-project.org/bundle/',
36
-            'lastmod' => '2012-12-26',
37
-            'change'  => 'daily',
38
-        ));
39
-        $writer->close();
40
-
41
-        $generatedFiles = $this->getFiles();
42
-
43
-        $this->assertEquals(2, count($generatedFiles));
44
-
45
-        // this will throw an exception if the xml is invalid
46
-        new SimpleXMLElement(file_get_contents($generatedFiles[1]));
47
-
48
-        $expected =<<<XML
49
-<?xml version="1.0" encoding="UTF-8"?>
50
-<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
51
-    <url><loc>http://sonata-project.org/bundle/</loc><lastmod>2012-12-26</lastmod><changefreq>weekly</changefreq><priority>0.5</priority></url>
52
-</urlset>
53
-XML;
54
-
55
-        $this->assertEquals(trim($expected), file_get_contents($generatedFiles[1]));
56
-    }
57
-
58
-    public function testSimpleWriteAdvanced()
59
-    {
60
-        $writer = new SitemapWriter($this->folder, 'test', array('image'), false);
61
-        $writer->open();
62
-        $writer->write(array(
63
-            'url'     => 'http://sonata-project.org/bundle/',
64
-            'lastmod' => '2012-12-26',
65
-            'change'  => 'daily',
66
-            'type'    => 'default',
67
-        ));
68
-        $writer->write(array(
69
-            'url'     => 'http://sonata-project.org/bundle/',
70
-            'lastmod' => '2012-12-26',
71
-            'change'  => 'weekly',
72
-            'type'    => 'image',
73
-            'images'  => array(
74
-                array(
75
-                    'url'     => 'http://sonata-project.org/uploads/media/default/0001/01/thumb_1_default_small.jpg',
76
-                    'caption' => 'sonata img'
77
-                )
78
-            )
79
-        ));
80
-        $writer->close();
81
-
82
-        $generatedFiles = $this->getFiles();
83
-
84
-        $this->assertEquals(1, count($generatedFiles));
85
-        $this->assertEquals($this->folder . '/sitemap_test_00001.xml', $generatedFiles[0]);
86
-
87
-        SitemapWriter::generateSitemapIndex($this->folder);
88
-
89
-        $generatedFiles = $this->getFiles();
90
-
91
-        $this->assertEquals(2, count($generatedFiles));
92
-
93
-        // this will throw an exception if the xml is invalid
94
-        new SimpleXMLElement(file_get_contents($generatedFiles[1]));
95
-
96
-        $expected =<<<XML
97
-<?xml version="1.0" encoding="UTF-8"?>
98
-<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
99
-    <url><loc>http://sonata-project.org/bundle/</loc><lastmod>2012-12-26</lastmod><changefreq>weekly</changefreq><priority>0.5</priority></url>
100
-    <url><loc>http://sonata-project.org/bundle/</loc><image:image><image:loc>http://sonata-project.org/uploads/media/default/0001/01/thumb_1_default_small.jpg</image:loc><image:caption>sonata img</image:caption></image:image></url>
101
-</urlset>
102
-XML;
103
-
104
-        $this->assertEquals(trim($expected), file_get_contents($generatedFiles[1]));
105
-    }
106
-
107
-    public function testLimitSize()
108
-    {
109
-        $writer = new SitemapWriter($this->folder);
110
-        $writer->open();
111
-
112
-        foreach (range(0, SitemapWriter::LIMIT_SIZE / 8196) as $i) {
113
-            $writer->write(array(
114
-                'url'     => str_repeat('x', 8196),
115
-                'lastmod' => 'now',
116
-                'change'  => 'daily'
117
-            ));
118
-        }
119
-        $writer->close();
120
-
121
-        $generatedFiles = $this->getFiles();
122
-
123
-        $this->assertEquals(3, count($generatedFiles));
124
-
125
-        // this will throw an exception if the xml is invalid
126
-        new SimpleXMLElement(file_get_contents($generatedFiles[1]));
127
-        new SimpleXMLElement(file_get_contents($generatedFiles[2]));
128
-
129
-        $info = stat($generatedFiles[1]);
130
-
131
-        $this->assertLessThan(SitemapWriter::LIMIT_SIZE, $info['size']);
132
-    }
133
-
134
-    public function testLimitUrl()
135
-    {
136
-        $writer = new SitemapWriter($this->folder);
137
-        $writer->open();
138
-
139
-        foreach (range(1, SitemapWriter::LIMIT_URL + 1) as $i) {
140
-            $writer->write(array(
141
-                'url'     => str_repeat('x', 40),
142
-                'lastmod' => 'now',
143
-                'change'  => 'daily'
144
-            ));
145
-        }
146
-        $writer->close();
147
-
148
-        $generatedFiles = $this->getFiles();
149
-
150
-        $this->assertEquals(3, count($generatedFiles));
151
-
152
-        // this will throw an exception if the xml is invalid
153
-        $file1 = new SimpleXMLElement(file_get_contents($generatedFiles[1]));
154
-        $file2 = new SimpleXMLElement(file_get_contents($generatedFiles[2]));
155
-
156
-        $info = stat($generatedFiles[0]);
157
-
158
-        $this->assertLessThan(SitemapWriter::LIMIT_SIZE, $info['size']);
159
-        $this->assertEquals(SitemapWriter::LIMIT_URL, count($file1->children()));
160
-        $this->assertEquals(1, count($file2->children()));
161
-    }
162
-
163
-    /**
164
-     * @return array
165
-     */
166
-    public function getFiles()
167
-    {
168
-        $files = glob($this->folder.'/*.xml');
169
-
170
-        sort($files);
171
-
172
-        return $files;
173
-    }
174
-
175
-    public function tearDown()
176
-    {
177
-        foreach ($this->getFiles() as $file) {
178
-            unlink($file);
179
-        }
180
-
181
-        if (is_dir($this->folder)) {
182
-            rmdir($this->folder);
183
-        }
184
-    }
185
-}

+ 0 - 12
vendor/sonata-project/exporter/test/bootstrap.php View File

@@ -1,12 +0,0 @@
1
-<?php
2
-
3
-spl_autoload_register(function($class) {
4
-    if (0 === strpos($class, 'Exporter\\')) {
5
-        $file = __DIR__ . '/../lib/' . str_replace('\\', '/', $class) . '.php';
6
-        if (file_exists($file)) {
7
-            require_once $file;
8
-
9
-            return true;
10
-        }
11
-    }
12
-});

+ 0 - 26
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/coffee.xml View File

@@ -1,26 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.coffee.class">Assetic\Filter\CoffeeScriptFilter</parameter>
9
-        <parameter key="assetic.filter.coffee.bin">/usr/bin/coffee</parameter>
10
-        <parameter key="assetic.filter.coffee.node">%assetic.node.bin%</parameter>
11
-        <parameter key="assetic.filter.coffee.timeout">null</parameter>
12
-        <parameter key="assetic.filter.coffee.node_paths">%assetic.node.paths%</parameter>
13
-        <parameter key="assetic.filter.coffee.bare">null</parameter>
14
-    </parameters>
15
-
16
-    <services>
17
-        <service id="assetic.filter.coffee" class="%assetic.filter.coffee.class%">
18
-            <tag name="assetic.filter" alias="coffee" />
19
-            <argument>%assetic.filter.coffee.bin%</argument>
20
-            <argument>%assetic.filter.coffee.node%</argument>
21
-            <call method="setTimeout"><argument>%assetic.filter.coffee.timeout%</argument></call>
22
-            <call method="setNodePaths"><argument>%assetic.filter.coffee.node_paths%</argument></call>
23
-            <call method="setBare"><argument>%assetic.filter.coffee.bare%</argument></call>
24
-        </service>
25
-    </services>
26
-</container>

+ 0 - 51
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/compass.xml View File

@@ -1,51 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.compass.class">Assetic\Filter\CompassFilter</parameter>
9
-        <parameter key="assetic.filter.compass.bin">/usr/bin/compass</parameter>
10
-        <parameter key="assetic.filter.compass.timeout">null</parameter>
11
-        <parameter key="assetic.filter.compass.debug">false</parameter>
12
-        <parameter key="assetic.filter.compass.no_line_comments">false</parameter>
13
-        <parameter key="assetic.filter.compass.style">null</parameter>
14
-        <parameter key="assetic.filter.compass.images_dir">null</parameter>
15
-        <parameter key="assetic.filter.compass.fonts_dir">null</parameter>
16
-        <parameter key="assetic.filter.compass.javascripts_dir">null</parameter>
17
-        <parameter key="assetic.filter.compass.http_path">null</parameter>
18
-        <parameter key="assetic.filter.compass.http_images_path">null</parameter>
19
-        <parameter key="assetic.filter.compass.http_fonts_path">null</parameter>
20
-        <parameter key="assetic.filter.compass.http_generated_images_path">null</parameter>
21
-        <parameter key="assetic.filter.compass.generated_images_path">null</parameter>
22
-        <parameter key="assetic.filter.compass.http_javascripts_path">null</parameter>
23
-        <parameter key="assetic.filter.compass.plugins" type="collection" />
24
-        <parameter key="assetic.filter.compass.load_paths" type="collection" />
25
-        <parameter key="assetic.filter.compass.home_env">true</parameter>
26
-    </parameters>
27
-
28
-    <services>
29
-        <service id="assetic.filter.compass" class="%assetic.filter.compass.class%">
30
-            <tag name="assetic.filter" alias="compass" />
31
-            <argument>%assetic.filter.compass.bin%</argument>
32
-            <argument>%assetic.ruby.bin%</argument>
33
-            <call method="setTimeout"><argument>%assetic.filter.compass.timeout%</argument></call>
34
-            <call method="setDebugInfo"><argument>%assetic.filter.compass.debug%</argument></call>
35
-            <call method="setNoLineComments"><argument>%assetic.filter.compass.no_line_comments%</argument></call>
36
-            <call method="setStyle"><argument>%assetic.filter.compass.style%</argument></call>
37
-            <call method="setImagesDir"><argument>%assetic.filter.compass.images_dir%</argument></call>
38
-            <call method="setFontsDir"><argument>%assetic.filter.compass.fonts_dir%</argument></call>
39
-            <call method="setJavascriptsDir"><argument>%assetic.filter.compass.javascripts_dir%</argument></call>
40
-            <call method="setHttpPath"><argument>%assetic.filter.compass.http_path%</argument></call>
41
-            <call method="setHttpImagesPath"><argument>%assetic.filter.compass.http_images_path%</argument></call>
42
-            <call method="setHttpFontsPath"><argument>%assetic.filter.compass.http_fonts_path%</argument></call>
43
-            <call method="setHttpGeneratedImagesPath"><argument>%assetic.filter.compass.http_generated_images_path%</argument></call>
44
-            <call method="setGeneratedImagesPath"><argument>%assetic.filter.compass.generated_images_path%</argument></call>
45
-            <call method="setHttpJavascriptsPath"><argument>%assetic.filter.compass.http_javascripts_path%</argument></call>
46
-            <call method="setPlugins"><argument>%assetic.filter.compass.plugins%</argument></call>
47
-            <call method="setLoadPaths"><argument>%assetic.filter.compass.load_paths%</argument></call>
48
-            <call method="setHomeEnv"><argument>%assetic.filter.compass.home_env%</argument></call>
49
-        </service>
50
-    </services>
51
-</container>

+ 0 - 36
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/cssembed.xml View File

@@ -1,36 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.cssembed.class">Assetic\Filter\CssEmbedFilter</parameter>
9
-        <parameter key="assetic.filter.cssembed.java">%assetic.java.bin%</parameter>
10
-        <parameter key="assetic.filter.cssembed.jar" />
11
-        <parameter key="assetic.filter.cssembed.timeout">null</parameter>
12
-        <parameter key="assetic.filter.cssembed.charset">%kernel.charset%</parameter>
13
-        <parameter key="assetic.filter.cssembed.mhtml">false</parameter>
14
-        <parameter key="assetic.filter.cssembed.mhtml_root">null</parameter>
15
-        <parameter key="assetic.filter.cssembed.root">null</parameter>
16
-        <parameter key="assetic.filter.cssembed.skip_missing">false</parameter>
17
-        <parameter key="assetic.filter.cssembed.max_uri_length">null</parameter>
18
-        <parameter key="assetic.filter.cssembed.max_image_size">null</parameter>
19
-    </parameters>
20
-
21
-    <services>
22
-        <service id="assetic.filter.cssembed" class="%assetic.filter.cssembed.class%">
23
-            <tag name="assetic.filter" alias="cssembed" />
24
-            <argument>%assetic.filter.cssembed.jar%</argument>
25
-            <argument>%assetic.filter.cssembed.java%</argument>
26
-            <call method="setTimeout"><argument>%assetic.filter.cssembed.timeout%</argument></call>
27
-            <call method="setCharset"><argument>%assetic.filter.cssembed.charset%</argument></call>
28
-            <call method="setMhtml"><argument>%assetic.filter.cssembed.mhtml%</argument></call>
29
-            <call method="setMhtmlRoot"><argument>%assetic.filter.cssembed.mhtml_root%</argument></call>
30
-            <call method="setRoot"><argument>%assetic.filter.cssembed.root%</argument></call>
31
-            <call method="setSkipMissing"><argument>%assetic.filter.cssembed.skip_missing%</argument></call>
32
-            <call method="setMaxUriLength"><argument>%assetic.filter.cssembed.max_uri_length%</argument></call>
33
-            <call method="setMaxImageSize"><argument>%assetic.filter.cssembed.max_image_size%</argument></call>
34
-        </service>
35
-    </services>
36
-</container>

+ 0 - 20
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/dart.xml View File

@@ -1,20 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.dart.class">Assetic\Filter\DartFilter</parameter>
9
-        <parameter key="assetic.filter.dart.bin">/usr/bin/dart2js</parameter>
10
-        <parameter key="assetic.filter.dart.timeout">null</parameter>
11
-    </parameters>
12
-
13
-    <services>
14
-        <service id="assetic.filter.dart" class="%assetic.filter.dart.class%">
15
-            <tag name="assetic.filter" alias="dart" />
16
-            <argument>%assetic.filter.dart.bin%</argument>
17
-            <call method="setTimeout"><argument>%assetic.filter.dart.timeout%</argument></call>
18
-        </service>
19
-    </services>
20
-</container>

+ 0 - 22
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/gss.xml View File

@@ -1,22 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.gss.class">Assetic\Filter\GssFilter</parameter>
9
-        <parameter key="assetic.filter.gss.java">%assetic.java.bin%</parameter>
10
-        <parameter key="assetic.filter.gss.jar" />
11
-        <parameter key="assetic.filter.gss.timeout">null</parameter>
12
-    </parameters>
13
-
14
-    <services>
15
-        <service id="assetic.filter.gss" class="%assetic.filter.gss.class%">
16
-            <tag name="assetic.filter" alias="gss" />
17
-            <argument>%assetic.filter.gss.jar%</argument>
18
-            <argument>%assetic.filter.gss.java%</argument>
19
-            <call method="setTimeout"><argument>%assetic.filter.gss.timeout%</argument></call>
20
-        </service>
21
-    </services>
22
-</container>

+ 0 - 28
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/handlebars.xml View File

@@ -1,28 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.handlebars.class">Assetic\Filter\HandlebarsFilter</parameter>
9
-        <parameter key="assetic.filter.handlebars.bin">/usr/bin/handlebars</parameter>
10
-        <parameter key="assetic.filter.handlebars.node">%assetic.node.bin%</parameter>
11
-        <parameter key="assetic.filter.handlebars.timeout">null</parameter>
12
-        <parameter key="assetic.filter.handlebars.node_paths">%assetic.node.paths%</parameter>
13
-        <parameter key="assetic.filter.handlebars.minimize">false</parameter>
14
-        <parameter key="assetic.filter.handlebars.simple">false</parameter>
15
-    </parameters>
16
-
17
-    <services>
18
-        <service id="assetic.filter.handlebars" class="%assetic.filter.handlebars.class%">
19
-            <tag name="assetic.filter" alias="handlebars" />
20
-            <argument>%assetic.filter.handlebars.bin%</argument>
21
-            <argument>%assetic.filter.handlebars.node%</argument>
22
-            <call method="setTimeout"><argument>%assetic.filter.handlebars.timeout%</argument></call>
23
-            <call method="setNodePaths"><argument>%assetic.filter.handlebars.node_paths%</argument></call>
24
-            <call method="setMinimize"><argument>%assetic.filter.handlebars.minimize%</argument></call>
25
-            <call method="setSimple"><argument>%assetic.filter.handlebars.simple%</argument></call>
26
-        </service>
27
-    </services>
28
-</container>

+ 0 - 24
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/jpegoptim.xml View File

@@ -1,24 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.jpegoptim.class">Assetic\Filter\JpegoptimFilter</parameter>
9
-        <parameter key="assetic.filter.jpegoptim.bin">/usr/bin/jpegoptim</parameter>
10
-        <parameter key="assetic.filter.jpegoptim.timeout">null</parameter>
11
-        <parameter key="assetic.filter.jpegoptim.strip_all">false</parameter>
12
-        <parameter key="assetic.filter.jpegoptim.max">null</parameter>
13
-    </parameters>
14
-
15
-    <services>
16
-        <service id="assetic.filter.jpegoptim" class="%assetic.filter.jpegoptim.class%">
17
-            <tag name="assetic.filter" alias="jpegoptim" />
18
-            <argument>%assetic.filter.jpegoptim.bin%</argument>
19
-            <call method="setTimeout"><argument>%assetic.filter.jpegoptim.timeout%</argument></call>
20
-            <call method="setStripAll"><argument>%assetic.filter.jpegoptim.strip_all%</argument></call>
21
-            <call method="setMax"><argument>%assetic.filter.jpegoptim.max%</argument></call>
22
-        </service>
23
-    </services>
24
-</container>

+ 0 - 28
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/jpegtran.xml View File

@@ -1,28 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.jpegtran.class">Assetic\Filter\JpegtranFilter</parameter>
9
-        <parameter key="assetic.filter.jpegtran.bin">/usr/bin/jpegtran</parameter>
10
-        <parameter key="assetic.filter.jpegtran.timeout">null</parameter>
11
-        <parameter key="assetic.filter.jpegtran.copy">null</parameter>
12
-        <parameter key="assetic.filter.jpegtran.optimize">false</parameter>
13
-        <parameter key="assetic.filter.jpegtran.progressive">false</parameter>
14
-        <parameter key="assetic.filter.jpegtran.restart">null</parameter>
15
-    </parameters>
16
-
17
-    <services>
18
-        <service id="assetic.filter.jpegtran" class="%assetic.filter.jpegtran.class%">
19
-            <tag name="assetic.filter" alias="jpegtran" />
20
-            <argument>%assetic.filter.jpegtran.bin%</argument>
21
-            <call method="setTimeout"><argument>%assetic.filter.jpegtran.timeout%</argument></call>
22
-            <call method="setCopy"><argument>%assetic.filter.jpegtran.copy%</argument></call>
23
-            <call method="setOptimize"><argument>%assetic.filter.jpegtran.optimize%</argument></call>
24
-            <call method="setProgressive"><argument>%assetic.filter.jpegtran.progressive%</argument></call>
25
-            <call method="setRestart"><argument>%assetic.filter.jpegtran.restart%</argument></call>
26
-        </service>
27
-    </services>
28
-</container>

+ 0 - 24
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/less.xml View File

@@ -1,24 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.less.class">Assetic\Filter\LessFilter</parameter>
9
-        <parameter key="assetic.filter.less.node">%assetic.node.bin%</parameter>
10
-        <parameter key="assetic.filter.less.node_paths">%assetic.node.paths%</parameter>
11
-        <parameter key="assetic.filter.less.timeout">null</parameter>
12
-        <parameter key="assetic.filter.less.compress">null</parameter>
13
-    </parameters>
14
-
15
-    <services>
16
-        <service id="assetic.filter.less" class="%assetic.filter.less.class%">
17
-            <tag name="assetic.filter" alias="less" />
18
-            <argument>%assetic.filter.less.node%</argument>
19
-            <argument>%assetic.filter.less.node_paths%</argument>
20
-            <call method="setTimeout"><argument>%assetic.filter.less.timeout%</argument></call>
21
-            <call method="setCompress"><argument>%assetic.filter.less.compress%</argument></call>
22
-        </service>
23
-    </services>
24
-</container>

+ 0 - 26
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/lessphp.xml View File

@@ -1,26 +0,0 @@
1
-<?xml version="1.0" ?>
2
-
3
-<container xmlns="http://symfony.com/schema/dic/services"
4
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
-    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
-
7
-    <parameters>
8
-        <parameter key="assetic.filter.lessphp.class">Assetic\Filter\LessphpFilter</parameter>
9
-        <parameter key="assetic.filter.lessphp.presets" type="collection"></parameter>
10
-        <!--
11
-        "formatter" can be set to one of: "lessjs", "compressed", "classic".
12
-        See http://leafo.net/lessphp/docs/#output_formatting
13
-        -->
14
-        <parameter key="assetic.filter.lessphp.formatter">null</parameter>
15
-        <parameter key="assetic.filter.lessphp.preserve_comments">null</parameter>
16
-    </parameters>
17
-
18
-    <services>
19
-        <service id="assetic.filter.lessphp" class="%assetic.filter.lessphp.class%">
20
-            <tag name="assetic.filter" alias="lessphp" />
21
-            <call method="setPresets"><argument>%assetic.filter.lessphp.presets%</argument></call>
22
-            <call method="setFormatter"><argument>%assetic.filter.lessphp.formatter%</argument></call>
23
-            <call method="setPreserveComments"><argument>%assetic.filter.lessphp.preserve_comments%</argument></call>
24
-        </service>
25
-    </services>
26
-</container>

+ 0 - 0
vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Resources/config/filters/optipng.xml View File


Some files were not shown because too many files changed in this diff