1 | <?php |
||
28 | class RepositoryHelper { |
||
29 | |||
30 | use EntityManagerTrait; |
||
31 | |||
32 | /** |
||
33 | * Service name. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | const SERVICE_NAME = "wbw.core.repository.repository_helper"; |
||
38 | |||
39 | /** |
||
40 | * SQL query. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | const SQL_QUERY = <<< EOT |
||
45 | SELECT |
||
46 | '%table%' AS 'table', |
||
47 | '%entity%' AS 'entity', |
||
48 | '%column%' AS 'column', |
||
49 | '%field%' AS 'field', |
||
50 | %available% AS 'available', |
||
51 | MIN(LENGTH(`%column%`)) AS 'minimum', |
||
52 | MAX(LENGTH(`%column%`)) AS 'maximum', |
||
53 | AVG(LENGTH(`%column%`)) AS 'average', |
||
54 | COUNT(`%column%`) AS 'count' |
||
55 | FROM `%table%` |
||
56 | EOT; |
||
57 | |||
58 | /** |
||
59 | * Constructor. |
||
60 | * |
||
61 | * @param EntityManagerInterface $entityManager The entity manager. |
||
62 | */ |
||
63 | public function __construct(EntityManagerInterface $entityManager) { |
||
66 | |||
67 | /** |
||
68 | * Execute a statement. |
||
69 | * |
||
70 | * @param Statement $statement The statement. |
||
71 | * @return RepositoryReport|null Returns the repository report in case of success, null otherwise. |
||
72 | */ |
||
73 | protected function executeStatement(Statement $statement) { |
||
95 | |||
96 | /** |
||
97 | * Get a repository report sort closure. |
||
98 | * |
||
99 | * @return Closure Returns the repository report sort closure. |
||
100 | */ |
||
101 | public static function getRepositoryReportSortClosure() { |
||
112 | |||
113 | /** |
||
114 | * Prepare a statement. |
||
115 | * |
||
116 | * @param string $table The table. |
||
117 | * @param string $entity The entity. |
||
118 | * @param string $field The field. |
||
119 | * @param int $available The available. |
||
120 | * @param string $column The column. |
||
121 | * @return Statement Returns the statement. |
||
122 | * @throws DBALException Throws a DBAL exception. |
||
123 | */ |
||
124 | protected function prepareStatement($table, $entity, $field, $available, $column) { |
||
133 | |||
134 | /** |
||
135 | * Read the repositories. |
||
136 | * |
||
137 | * @return RepositoryReport[] Returns the repository reports. |
||
138 | * @throws DBALException Throws a DBAL exception. |
||
139 | * @throws MappingException Throws a mapping exception. |
||
140 | */ |
||
141 | public function readRepositories() { |
||
160 | |||
161 | /** |
||
162 | * Read a repository. |
||
163 | * |
||
164 | * @param ClassMetadata $classMetadata The class metadata. |
||
165 | * @return RepositoryReport[] Returns the repository reports. |
||
166 | * @throws DBALException Throws a DBAL exception. |
||
167 | * @throws MappingException Throws a mapping exception. |
||
168 | */ |
||
169 | protected function readRepository(ClassMetadata $classMetadata) { |
||
196 | } |
||
197 |