| Conditions | 2 |
| Paths | 2 |
| Total Lines | 90 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 55 | public function createFindQuery(array $translations = null) |
||
| 56 | { |
||
| 57 | /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */ |
||
| 58 | $query = $this->dbHandler->createSelectQuery(); |
||
| 59 | $query->select( |
||
| 60 | // Content object |
||
| 61 | $this->dbHandler->aliasedColumn($query, 'id', 'ezcontentobject'), |
||
| 62 | $this->dbHandler->aliasedColumn($query, 'contentclass_id', 'ezcontentobject'), |
||
| 63 | $this->dbHandler->aliasedColumn($query, 'section_id', 'ezcontentobject'), |
||
| 64 | $this->dbHandler->aliasedColumn($query, 'owner_id', 'ezcontentobject'), |
||
| 65 | $this->dbHandler->aliasedColumn($query, 'remote_id', 'ezcontentobject'), |
||
| 66 | $this->dbHandler->aliasedColumn($query, 'current_version', 'ezcontentobject'), |
||
| 67 | $this->dbHandler->aliasedColumn($query, 'initial_language_id', 'ezcontentobject'), |
||
| 68 | $this->dbHandler->aliasedColumn($query, 'modified', 'ezcontentobject'), |
||
| 69 | $this->dbHandler->aliasedColumn($query, 'published', 'ezcontentobject'), |
||
| 70 | $this->dbHandler->aliasedColumn($query, 'status', 'ezcontentobject'), |
||
| 71 | $this->dbHandler->aliasedColumn($query, 'name', 'ezcontentobject'), |
||
| 72 | $this->dbHandler->aliasedColumn($query, 'language_mask', 'ezcontentobject'), |
||
| 73 | // Content object version |
||
| 74 | $this->dbHandler->aliasedColumn($query, 'id', 'ezcontentobject_version'), |
||
| 75 | $this->dbHandler->aliasedColumn($query, 'version', 'ezcontentobject_version'), |
||
| 76 | $this->dbHandler->aliasedColumn($query, 'modified', 'ezcontentobject_version'), |
||
| 77 | $this->dbHandler->aliasedColumn($query, 'creator_id', 'ezcontentobject_version'), |
||
| 78 | $this->dbHandler->aliasedColumn($query, 'created', 'ezcontentobject_version'), |
||
| 79 | $this->dbHandler->aliasedColumn($query, 'status', 'ezcontentobject_version'), |
||
| 80 | // @todo: remove ezcontentobject_version.contentobject_id from query as it duplicates ezcontentobject.id |
||
| 81 | $this->dbHandler->aliasedColumn($query, 'contentobject_id', 'ezcontentobject_version'), |
||
| 82 | $this->dbHandler->aliasedColumn($query, 'language_mask', 'ezcontentobject_version'), |
||
| 83 | $this->dbHandler->aliasedColumn($query, 'initial_language_id', 'ezcontentobject_version'), |
||
| 84 | // Content object fields |
||
| 85 | $this->dbHandler->aliasedColumn($query, 'id', 'ezcontentobject_attribute'), |
||
| 86 | $this->dbHandler->aliasedColumn($query, 'contentclassattribute_id', 'ezcontentobject_attribute'), |
||
| 87 | $this->dbHandler->aliasedColumn($query, 'data_type_string', 'ezcontentobject_attribute'), |
||
| 88 | $this->dbHandler->aliasedColumn($query, 'language_code', 'ezcontentobject_attribute'), |
||
| 89 | $this->dbHandler->aliasedColumn($query, 'language_id', 'ezcontentobject_attribute'), |
||
| 90 | // @todo: remove ezcontentobject_attribute.version from query as it duplicates ezcontentobject_version.version |
||
| 91 | $this->dbHandler->aliasedColumn($query, 'version', 'ezcontentobject_attribute'), |
||
| 92 | // Content object field data |
||
| 93 | $this->dbHandler->aliasedColumn($query, 'data_float', 'ezcontentobject_attribute'), |
||
| 94 | $this->dbHandler->aliasedColumn($query, 'data_int', 'ezcontentobject_attribute'), |
||
| 95 | $this->dbHandler->aliasedColumn($query, 'data_text', 'ezcontentobject_attribute'), |
||
| 96 | $this->dbHandler->aliasedColumn($query, 'sort_key_int', 'ezcontentobject_attribute'), |
||
| 97 | $this->dbHandler->aliasedColumn($query, 'sort_key_string', 'ezcontentobject_attribute'), |
||
| 98 | // Content object locations |
||
| 99 | $this->dbHandler->aliasedColumn($query, 'main_node_id', 'ezcontentobject_tree') |
||
| 100 | )->from( |
||
| 101 | $this->dbHandler->quoteTable('ezcontentobject') |
||
| 102 | )->innerJoin( |
||
| 103 | $this->dbHandler->quoteTable('ezcontentobject_version'), |
||
| 104 | $query->expr->eq( |
||
| 105 | $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_version'), |
||
| 106 | $this->dbHandler->quoteColumn('id', 'ezcontentobject') |
||
| 107 | ) |
||
| 108 | )->innerJoin( |
||
| 109 | $this->dbHandler->quoteTable('ezcontentobject_attribute'), |
||
| 110 | $query->expr->lAnd( |
||
| 111 | $query->expr->eq( |
||
| 112 | $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_attribute'), |
||
| 113 | $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_version') |
||
| 114 | ), |
||
| 115 | $query->expr->eq( |
||
| 116 | $this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute'), |
||
| 117 | $this->dbHandler->quoteColumn('version', 'ezcontentobject_version') |
||
| 118 | ) |
||
| 119 | ) |
||
| 120 | )->leftJoin( |
||
| 121 | $this->dbHandler->quoteTable('ezcontentobject_tree'), |
||
| 122 | $query->expr->lAnd( |
||
| 123 | $query->expr->eq( |
||
| 124 | $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_tree'), |
||
| 125 | $this->dbHandler->quoteColumn('id', 'ezcontentobject') |
||
| 126 | ), |
||
| 127 | $query->expr->eq( |
||
| 128 | $this->dbHandler->quoteColumn('main_node_id', 'ezcontentobject_tree'), |
||
| 129 | $this->dbHandler->quoteColumn('node_id', 'ezcontentobject_tree') |
||
| 130 | ) |
||
| 131 | ) |
||
| 132 | ); |
||
| 133 | |||
| 134 | if (!empty($translations)) { |
||
| 135 | $query->where( |
||
| 136 | $query->expr->in( |
||
| 137 | $this->dbHandler->quoteColumn('language_code', 'ezcontentobject_attribute'), |
||
| 138 | $translations |
||
| 139 | ) |
||
| 140 | ); |
||
| 141 | } |
||
| 142 | |||
| 143 | return $query; |
||
| 144 | } |
||
| 145 | |||
| 316 |