protected function createPath(EntityInterface $entity, $field, array $settings, ProfferPathInterface $path = null)
    {
        if (!empty($settings['pathClass'])) {
            $path = new $settings['pathClass']($this->_table, $entity, $field, $settings);
            if (!$path instanceof ProfferPathInterface) {
                throw new InvalidClassException("Class {$settings['pathClass']} does not implement the ProfferPathInterface.");
            }
        } elseif (!isset($path)) {
            $path = new ProfferPath($this->_table, $entity, $field, $settings);
        }

        $event = new Event('Proffer.afterPath', $entity, ['path' => $path]);
        $this->_table->getEventManager()->dispatch($event);
        if (!empty($event->result)) {
            $path = $event->result;
        }

        $path->createPathFolder();

        return $path;
    }