-
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.
Merge branch 'main' into feat/behat-definitions-user
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
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"); | ||
} | ||
} | ||
|
||
} |
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