| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace App\Blog\Widget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use App\Blog\Entity\Post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Yiisoft\Html\Html; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Yiisoft\Router\UrlGeneratorInterface; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Yiisoft\Yii\Bootstrap5\Widget; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | final class PostCard extends Widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     private ?Post $post = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     private array $options = []; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     public function __construct(private UrlGeneratorInterface $urlGenerator) | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     public function render(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         if (!isset($this->options['id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             $this->options['id'] = "{$this->getId()}-post-card"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->initOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         return implode("\n", [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             Html::openTag('div', $this->options), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             Html::openTag('div', ['class' => 'card-body d-flex flex-column align-items-start']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             $this->renderHead(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             $this->renderBody(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             $this->renderTags(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             Html::closeTag('div'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             Html::closeTag('div'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     protected function renderHead(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         return Html::a( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             $this->post->getTitle(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             $this->urlGenerator->generate('blog/post', ['slug' => $this->post->getSlug()]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             ['class' => 'mb-0 h4 text-decoration-none'] // stretched-link | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             ->render(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     protected function renderBody(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $return = Html::openTag('div', ['class' => 'card-text mb-auto']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $return .= $this->post->getPublishedAt() === null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             ? 'not published' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             : $this->post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                 ->getPublishedAt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 ->format('M, d'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $return .= ' by '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $return .= Html::a( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             $this->post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 ->getUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                 ->getLogin(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             $this->urlGenerator->generate('user/profile', ['login' => $this->post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 ->getUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 ->getLogin(), ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         )->class('mb-1 text-muted'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $return .= Html::p( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             mb_substr($this->post->getContent(), 0, 400) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             . (mb_strlen($this->post->getContent()) > 400 ? '…' : '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         return $return . Html::closeTag('div'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     protected function renderTags(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $return = Html::openTag('div', ['class' => 'mt-3']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         foreach ($this->post->getTags() as $tag) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             $return .= Html::a( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                 $tag->getLabel(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                 $this->urlGenerator->generate('blog/tag', ['label' => $tag->getLabel()]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 ['class' => 'btn btn-outline-secondary btn-sm me-2 mt-1'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         return $return . Html::closeTag('div'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     protected function initOptions(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         Html::addCssClass($this->options, ['widget' => 'card mb-4']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     public function post(?Post $post): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->post = $post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         if ($post !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             $this->options['data']['post-slug'] = $post->getSlug(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * The HTML attributes for the widget container tag. The following special options are recognized. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * {@see \Yiisoft\Html\Html::renderTagAttributes()} for details on how attributes are being rendered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function options(array $value): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $this->options = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 118 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 119 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths