prepare(); } /** * Retrieves the list of available symbol classes, * creates objects of these classes and stores them. * * @return void */ protected function prepare() { $symbol_registry = $this->symbol_registry; /** * Filtered registered symbols on calculators * * @since 1.7 * * @param string[] $symbol_registry * * @return string[] */ $symbol_registry = apply_filters( 'forminator_calculator_symbol_registry', $symbol_registry ); foreach ( $symbol_registry as $symbol_class_name ) { $symbol = new $symbol_class_name(); $this->symbols[ $symbol_class_name ] = $symbol; } } /** * Returns the symbol that has the given identifier. * Returns null if none is found. * * @param string $identifier Identifier. * * @return Forminator_Calculator_Symbol_Abstract|null */ public function find( $identifier ) { // allow strict compare with strtolower. $identifier = strtolower( $identifier ); foreach ( $this->symbols as $symbol ) { if ( in_array( $identifier, $symbol->get_identifiers(), true ) ) { return $symbol; } } return null; } /** * Returns all symbols that inherit from a given abstract * parent type (class): The parent type has to be an * AbstractSymbol. * Notice: The parent type name will not be validated! * * @param string $parent_type_name Parent type name. * * @return Forminator_Calculator_Symbol_Abstract[] */ public function find_sub_types( $parent_type_name ) { $symbols = array(); foreach ( $this->symbols as $symbol ) { if ( $symbol instanceof $parent_type_name ) { $symbols[] = $symbol; } } return $symbols; } }