Skip to content

Commit

Permalink
Merge pull request #637 from rmdstudio/master
Browse files Browse the repository at this point in the history
hashtags
  • Loading branch information
rmdstudio authored Dec 7, 2022
2 parents 3282f4c + 620e28a commit f4d75a2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
<?= sprintf(@text('COM-ARTICLES-STORY-ARTICLE-ADD'), @name($subject), @route($object->getURL())) ?>
</data>

<data name="body">
<? if ($object->hasCover()): ?>
<div class="entity-portrait-medium">
<?= @cover($object, 'medium') ?>
</div>
<? endif ?>

<data name="body">
<h4 class="entity-title">
<?= @link($object)?>
</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
</data>

<data name="body">
<? if ($object->hasCover()): ?>
<div class="entity-portrait-medium">
<?= @cover($object, 'medium') ?>
</div>
<? endif ?>

<h4 class="entity-title">
<?= @link($object) ?>
</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function updateHashtagsFromBody(AnCommandContext $context)

if (is_array($terms)) {
foreach ($entity->hashtags as $hashtag) {
if (!in_array($hashtag->name, array_map('strtolower', $terms))) {
if (!in_array(strtolower($hashtag->name), array_map('strtolower', $terms))) {
$entity->removeHashtag($hashtag->name);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _initialize(AnConfig $config)
'relationships' => array(
'hashtags' => array(
'through' => 'com:hashtags.domain.entity.tag',
'target' => str_replace('repository', 'entity', $identifier),
'target' => $config->target ? $config->target : 'com:base.domain.entity.node',
'child_key' => 'taggable',
'target_child_key' => 'hashtag',
'inverse' => true,
Expand Down
11 changes: 6 additions & 5 deletions src/components/com_hashtags/domains/entities/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ protected function _initialize(AnConfig $config)
'hashtag' => 'nodeA',
),
'relationships' => array(
'hashtag' => array('parent' => 'com:hashtags.domain.entity.hashtag'),
'hashtag' => array(
'parent' => 'com:hashtags.domain.entity.hashtag'),
),
));

Expand All @@ -52,6 +53,10 @@ protected function _afterEntityInsert(AnCommandContext $context)
protected function _afterEntityDelete(AnCommandContext $context)
{
$this->resetStats();

if (count($this->hashtag->taggables) === 0) {
$this->hashtag->delete();
}
}

/**
Expand All @@ -62,9 +67,5 @@ protected function _afterEntityDelete(AnCommandContext $context)
private function resetStats()
{
$this->hashtag->resetStats(array($this->hashtag));

if (count($this->hashtag->taggables) === 0) {
$this->hashtag->delete();
}
}
}

0 comments on commit f4d75a2

Please sign in to comment.