| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 36 | protected function getIdByArguments($title, $contentType = '') |
||
| 37 | { |
||
| 38 | $nid = new FetchField('node', 'nid'); |
||
| 39 | $nid->condition('title', "%$title", 'like'); |
||
| 40 | |||
| 41 | // Try to recognize node type by its title if content type specified and does not exist. |
||
| 42 | if ('' !== $contentType && !isset(node_type_get_types()[$contentType])) { |
||
| 43 | $contentType = (new FetchField('node_type', 'type')) |
||
| 44 | ->condition('name', $contentType) |
||
| 45 | ->execute(); |
||
| 46 | |||
| 47 | if ('' === $contentType) { |
||
| 48 | throw new \InvalidArgumentException('Content type with such name does not exist!'); |
||
| 49 | } |
||
| 50 | |||
| 51 | $nid->condition('type', $contentType); |
||
| 52 | } |
||
| 53 | |||
| 54 | return $nid->execute(); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |