ancestor() public method

Example: $key->ancestor('Person', 'Jane'); In cases where the identifier type is ambiguous, you can choose the type to be used. $key->ancestor('Robots', '1337', [ 'identifierType' => Key::TYPE_NAME ]);
See also: https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement
public ancestor ( string $kind, string | integer $identifier, array $options = [] ) : Key
$kind string The kind.
$identifier string | integer The name or ID of the object.
$options array { Configuration Options @type string $identifierType [optional] If omitted, the type will be determined internally. Setting this to either `Key::TYPE_ID` or `Key::TYPE_NAME` will force the pathElement identifier type. }
return Key
コード例 #1
0
ファイル: KeyTest.php プロジェクト: Radiergummi/anacronism
 public function testAncestor()
 {
     $key = new Key('foo', ['path' => [['kind' => 'thing']]]);
     $key->ancestor('Hello', 'World');
     $this->assertEquals(['kind' => 'Hello', 'name' => 'World'], $key->keyObject()['path'][0]);
     $this->assertEquals(['kind' => 'thing'], $key->keyObject()['path'][1]);
 }