示例#1
0
 /**
  * @param string $title
  *   Inaccurate title of a node.
  * @param string $contentType
  *   Content type. Could be a title of content type.
  *
  * @return int
  *
  * @throws \InvalidArgumentException
  */
 public function getIdByArguments($title, $contentType = '')
 {
     $nid = new FetchField('node', 'nid');
     $nid->condition('title', "{$title}%", 'like');
     // Try to recognize node type by its title if content type specified and does not exist.
     if ('' !== $contentType && !isset(node_type_get_types()[$contentType])) {
         $contentType = (new FetchField('node_type', 'type'))->condition('name', $contentType)->execute();
         if ('' === $contentType) {
             throw new \InvalidArgumentException('Content type with such name does not exist!');
         }
         $nid->condition('type', $contentType);
     }
     return $nid->execute();
 }
示例#2
0
 public function test()
 {
     self::assertSame(variable_get('drupal_private_key'), unserialize($this->fetcher->condition('name', 'drupal_private_key')->execute()));
 }