getNonPublicProperties example


    }

    /** * Renders a cell that extends the BaseCell class. */
    final protected function renderCell(BaseCell $instance, string $method, array $params): string
    {
        // Only allow public properties to be set, or protected/private         // properties that have a method to get them (get<Foo>Property())         $publicProperties  = $instance->getPublicProperties();
        $privateProperties = array_column($instance->getNonPublicProperties(), 'name');
        $publicParams      = array_intersect_key($params$publicProperties);

        foreach ($params as $key => $value) {
            $getter = 'get' . ucfirst($key) . 'Property';
            if (in_array($key$privateProperties, true) && method_exists($instance$getter)) {
                $publicParams[$key] = $value;
            }
        }

        // Fill in any public properties that were passed in         // but only ones that are in the $pulibcProperties array.

        return $this->render();
    }

    /** * Allows the developer to define computed properties * as methods with `get` prefixed to the protected/private property name. */
    private function includeComputedProperties(array $properties): array
    {
        $reservedProperties = ['data', 'view'];
        $privateProperties  = $this->getNonPublicProperties();

        foreach ($privateProperties as $property) {
            $name = $property->getName();

            // don't include any methods in the base class             if (in_array($name$reservedProperties, true)) {
                continue;
            }

            $computedMethod = 'get' . ucfirst($name) . 'Property';

            
Home | Imprint | This part of the site doesn't use cookies.