-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Eirik Stanghelle Morland <[email protected]>
- Loading branch information
1 parent
bd78952
commit e9b76e8
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Frontkom\DrupalBehatDefinitions; | ||
|
||
use Drupal\DrupalExtension\Context\RawDrupalContext; | ||
|
||
/** | ||
* Class ContentContext. | ||
* | ||
* Provide Behat step-definitions for content related operations. | ||
*/ | ||
class ContentContext extends RawDrupalContext { | ||
|
||
/** | ||
* Unpublish the chosed term. | ||
* | ||
* @Then I unpublish term :name | ||
*/ | ||
public function iUnpublishTerm($name) { | ||
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term') | ||
->loadByProperties(['name' => $name]); | ||
|
||
if ($term) { | ||
$term = reset($term); | ||
$term->setUnpublished(); | ||
$term->save(); | ||
} | ||
else { | ||
throw new \Exception("Term with name '$name' not found"); | ||
} | ||
} | ||
|
||
} |