Patch an existing $device with a $patchingDevice

@param \Wurfl\Device\ModelDeviceInterface $device
@param \Wurfl\Device\ModelDeviceInterface $patchingDevice

@return \Wurfl\Device\ModelDeviceInterface Patched device
15728
public function patch(ModelDeviceInterface $device, ModelDeviceInterface $patchingDevice)
    {
        if (!$this->haveSameId($device, $patchingDevice)) {
            return $patchingDevice;
        }

        $groupIdCapabilitiesMap = Utils::arrayMergeRecursiveUnique(
            $device->getGroupIdCapabilitiesMap(),
            $patchingDevice->getGroupIdCapabilitiesMap()
        );

        return new ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $device->specific, $groupIdCapabilitiesMap);
    }
423244
protected function replaceTemplateExtension($name, $device)
    {
        if (strstr($name, 'twig')) {
            return str_replace('html.twig', $device . '.html.twig', $name);
        }
        if (strstr($name, 'smarty')) {
            return str_replace('html.smarty', $device . '.html.smarty', $name);
        }

        return $name;
    }
684673
public function patch(
        string $definition,
        RequestHandlerInterface $handler,
        ?string $name = null,
        $data = null
    ): Route {
        return $this->route(Method::PATCH, $definition, $handler, $name, $data);
    }
530923
private function init()
    {
        $devicePatcher           = new Device\Xml\DevicePatcher();
        $deviceRepositoryBuilder = new Device\DeviceRepositoryBuilder(
            $this->getPersistenceStorage(),
            $this->getUserAgentHandlerChain(),
            $devicePatcher,
            $this->getLogger()
        );

        $this->deviceRepository = $deviceRepositoryBuilder->build(
            $this->getWurflConfig()->wurflFile,
            $this->getWurflConfig()->wurflPatches,
            $this->getWurflConfig()->capabilityFilter
        );
    }
1061882
public static function set_user_device_type($newdevice) {
        $devicetype = self::get_device_type();
        if ($newdevice == $devicetype) {
            unset_user_preference('switchdevice'.$devicetype);
            return true;
        } else {
            $devicetypes = self::get_device_type_list();
            if (in_array($newdevice, $devicetypes)) {
                set_user_preference('switchdevice'.$devicetype, $newdevice);
                return true;
            }
        }
        throw new coding_exception('Invalid device type provided to set_user_device_type');
    }
873732
public DbDevImportInfo import_device(final DeviceProxy deviceProxy) throws DevFailed {

        checkIfUseDb(deviceProxy, "import_device()");

        if (deviceProxy.getDb_dev() == null) {
            deviceProxy.setDb_dev(new DbDevice(deviceProxy.devname, deviceProxy.url.host,
                deviceProxy.url.strPort));
        }
        // checkIfTango("import_device");
        if (deviceProxy.url.protocol == TANGO) {
            return deviceProxy.getDb_dev().import_device();
        } else {
            return new DbDevImportInfo(dev_inform(deviceProxy));
        }
    }
819629
public function addDevice(\BlackForest\PiwikBundle\Entity\PiwikDevice $device)
    {
        $this->device[] = $device;

        return $this;
    }
384265
public static function build(GenericRequest $request, CustomDevice $customDevice)
    {
        $device = new Device($request);

        self::assignProperties($device, $customDevice);
        self::normalizeOS($device);
        self::normalizeBrowser($device);

        return $device;
    }
213945
private function validateDevice(ModelDeviceInterface $device)
    {
        // Must have a valid wurfl ID
        if (strlen($device->id) === 0) {
            return false;
        }

        // Must have a valid User Agent unless it's "generic"
        if (strlen($device->userAgent) === 0 && $device->id !== 'generic') {
            return false;
        }

        return true;
    }
1016226
public void addTangoInterfaceChangeListener(ITangoInterfaceChangeListener listener, String deviceName, boolean stateless)
            throws DevFailed {
        TangoInterfaceChange interfaceChange;
        if ((interfaceChange = tango_interface_change_source.get(deviceName)) == null) {
            interfaceChange = new TangoInterfaceChange(deviceProxy);
            tango_interface_change_source.put(deviceName, interfaceChange);
        }
        synchronized (moni) {
            interfaceChange.addTangoInterfaceChangeListener(listener, stateless);
        }
    }
1014558
protected function getDeviceIden($device)
    {
        foreach ($this->devices() as $available_device) {
            foreach (['iden', 'nickname'] as $field) {
                if ($available_device->$field == $device) {
                    return $available_device->iden;
                }
            }
        }

        return false;
    }
695214
public function open($device, $mode = "w+b")
    {
        if (false === file_exists($device)) {
            throw new DeviceNotFound();
        }

        $this->getConfigure()->configure($device);
        $this->fd = fopen($device, $mode);

        if (false !== $this->fd) {
            stream_set_blocking($this->fd, false);

            return true;
        }

        unset($this->fd);
        throw new DeviceNotAvailable($device);
    }
113443
public function getDeviceType()
    {
        if ($this->deviceType === null) {
            $this->setDeviceType($this->detectDeviceType());
        }

        return $this->deviceType;
    }
495334
public void connectDevice(Device device) throws ShanksException {
        if (this.linkedDevices.size() < deviceCapacity) {
            if (!this.linkedDevices.contains(device)) {
                this.linkedDevices.add(device);
                device.connectToLink(this);
                logger.finer("Link " + this.getID() + " has Device "
                        + device.getID() + " in its linked device list.");
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        } else {
            if (!this.linkedDevices.contains(device)) {
                logger.warning("Link " + this.getID()
                        + " is full of its capacity. Device " + device.getID()
                        + " was not included in its linked device list.");
                throw new TooManyConnectionException(this);
            } else {
                logger.finer("Link " + this.getID() + " already has Device "
                        + device.getID() + " in its linked device list.");
            }
        }
    }
987651
private function toArray(DeviceIterator $deviceIterator)
    {
        $patchingDevices = array();

        foreach ($deviceIterator as $device) {
            /* @var $device \Wurfl\Device\ModelDeviceInterface */
            $patchingDevices[$device->id] = $device;
        }

        return $patchingDevices;
    }
560382
private function checkIfCanPatch($device, $patchingDevice)
    {
        if (strcmp($patchingDevice->userAgent, $device->userAgent) !== 0) {
            $message = "Patch Device : " . $patchingDevice->id . " can't override user agent " . $device->userAgent . " with " . $patchingDevice->userAgent;
            throw new WURFL_WURFLException($message);
        }
    }
222227
public function patch(
        EnvironmentInterface $environment
    ) {
        foreach ($this->patchers as $patcher) {
            $patcher->patch($environment);
        }
    }