| Conditions | 3 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | public function iVisitNodePageOfType($operation, $title, $type) { |
||
| 15 | if ($operation == 'visit') { |
||
| 16 | $operation = 'view'; |
||
| 17 | } |
||
| 18 | $query = new \EntityFieldQuery(); |
||
| 19 | $result = $query |
||
| 20 | ->entityCondition('entity_type', 'node') |
||
| 21 | // @todo: Add support for CT label. |
||
| 22 | ->entityCondition('bundle', strtolower($type)) |
||
| 23 | ->propertyCondition('title', $title) |
||
| 24 | ->range(0, 1) |
||
| 25 | ->execute(); |
||
| 26 | |||
| 27 | if (empty($result['node'])) { |
||
| 28 | $params = array( |
||
| 29 | '@title' => $title, |
||
| 30 | '@type' => $type, |
||
| 31 | ); |
||
| 32 | throw new \Exception(format_string("Node @title of @type not found.", $params)); |
||
| 33 | } |
||
| 34 | |||
| 35 | $nid = key($result['node']); |
||
| 36 | $this->getSession()->visit($this->locatePath('/node/' . $nid . '/' . $operation)); |
||
| 37 | } |
||
| 38 | |||
| 52 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: